Skip to content

Instantly share code, notes, and snippets.

@sorenmalling
Created April 23, 2013 12:00
Show Gist options
  • Save sorenmalling/5443008 to your computer and use it in GitHub Desktop.
Save sorenmalling/5443008 to your computer and use it in GitHub Desktop.
renderObj = COA
renderObj {
wrap = <ul>|</ul>
1 = TEXT
1 {
wrap = <li>|</li>
typolink {
parameter.field = link
}
field = title
}
}
Using
$this->cObj->cObjGetSingle($this->conf[$endpoint . '.']['renderObj'], $this->conf[$endpoint . '.']['renderObj.']);
outputs
<ul>
<li>
<a href="..." >Element 1</a>
</li>
</ul>
<ul>
<li>
<a href="..." >Element 2</a>
</li>
</ul>
would like
<ul>
<li>
<a href="..." >Element 1</a>
</li>
<li>
<a href="..." >Element 2</a>
</li>
</ul>
@smichaelsen
Copy link

the wrap should no be inside renderObj. I can't suggest a solution because I don't really get the context by the code you provided. Either way the ul wrap has to be "one level above".

@sorenmalling
Copy link
Author

I will be creating a <ul><li></li></ul> list with data from a external service (Disqus)

            $response = json_decode($disqusService->request());
            foreach ($response->response as $response) {
                    $this->cObj->data = get_object_vars($response);
                    $content .= $this->cObj->cObjGetSingle($this->conf[$endpoint . '.']['renderObj'], $this->conf[$endpoint . '.']['renderObj.']);
            }

If i move the wrap part on level up, example:

[endpoint name] {
  render {
    wrap = <ul>|<ul>
    renderObj {
      [like above]
    }
  }
}

How do I code-wise apply the <ul> (wrap) correctly

@peterkraume
Copy link

I'd do it this way:
$content .= $this->cObj->wrap($this->cObj->cObjGetSingle($this->conf[$endpoint . '.']['renderObj'], $this->conf[$endpoint . '.']['renderObj.']), '

    |
');

@smichaelsen
Copy link

Something like:

[endpoint name] {
  stdWrap.wrap = <ul>|<ul>
  renderObj {
    [like above]
  }
}
$response = json_decode($disqusService->request());
$listcontent = '';
foreach ($response->response as $response) {
   $this->cObj->data = get_object_vars($response);
   $listcontent .= $this->cObj->cObjGetSingle($this->conf[$endpoint . '.']['renderObj'], $this->conf[$endpoint . '.']['renderObj.']);
}
$listcontent = $this->cObj->stdWrap($listcontent, $this->conf[$endpoint . '.']['stdWrap.']);
$content .= $listcontent;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment