Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

renderWith() what control object to use???

Go to End

6 Posts   5341 Views


Community Member, 79 Posts

14 June 2011 at 6:11pm

Edited: 14/06/2011 6:12pm

Hi Guys,

I am struggling a little with this... Obviously it is going to be a really simple answer, but I just can't crack it at the moment.

I am creating a browse page with ajax links to show more items.

So I have the AJAX working fine but my main problem is that I can get the dataobject to actually pass information through to the new template I a calling with renderWith(). I have tested and there is info in the dataobject it is just my lack of understand which value I should be using in the template I think

Function to return a list of books

    public function books() {
        $books = DataObject::get('Book', "ItemType = 'have' AND Status = 'available'", 'Created DESC, Value DESC', '');
        return $this->renderWith('BrowsePage_Books');

Template =

<div id="AllBooks" class="categoryBoxes">
	<h2>Latest Books <a href="">View all Books</a></h2>
        <ul id="ProductListing" class="productListing">
        <% control Book %>
                <li class="$FirstLast">
			<a href="" class="productImage">
                        <% control ItemImage1 %>
                                 <img src="$CroppedImage(104,104).URL" alt="$Title" class="entry-image" />
                        <% end_control %>
			<p class="productTitleContainer"><a href="" class="productTitle">$Title :: $Author</a></p>
				<a href="" class="getItemLink">Get Item</a>
       <% end_control %>
	<div style="clear:both;"></div>

I saw this post and so I tried [url=]

<% control Me %>

But still no luck... Obviously I am just not in the right context, but struggling to work out which context I should be in... Any help appreciated.



Community Member, 12 Posts

14 June 2011 at 8:31pm

hey colin, u need to pass the data back to the template.

try something like:

$books = DataObject::get('Book', "ItemType = 'have' AND Status = 'available'", 'Created DESC, Value DESC', '');
$this->customize(array('books' => $books))->renderWith('BrowsePage_Books');


Community Member, 90 Posts

16 June 2011 at 9:50am

@ccburns 's solution is correct.

you cannot do:

return $this->renderWith('BrowsePage_Books'); it will not passing the data back to your template.

The $this->customize(array("$key"=>$value))->renderwith('Template') would do the trick.


Community Member, 79 Posts

16 June 2011 at 4:57pm

Thanks guys, your spot on... Thanks


Community Member, 4 Posts

29 July 2011 at 12:21pm

I am having a similar confusion. But I can't do this:

because the function customize() doesn't exist. Am I missing something?

I'm trying to put together some data and pass it on to the template. It is in the page controller I am trying to call $this->customize()



Forum Moderator, 5523 Posts

29 July 2011 at 7:51pm