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

Displaying DataObject properties in a template


Reply

3 Posts   1897 Views

Avatar
baba-papa

4 October 2009 at 12:41am (Last edited: 4 October 2009 12:42am), Community Member, 279 Posts

Hello,

I implemented the search of dataobjects to my site. The search works, here is the search form´s action method:

function doSearch($data, $form) {
$StudioPostcodeQuery = $data['StudioPostcodeQuery'];
$id = $this->ID;
$StudioSearchResults = DataObject::get('FitnessStudio', "FitnessStudio.campaignID = '$id' AND FitnessStudio.postcode = '$StudioPostcodeQuery'");
$data = array(
'Results' => $StudioSearchResults,
'Title' => 'Surchergebnisse'
);
return $this->customise($data)->renderWith(array('StudioSearch_results', 'Page'));
}


The results template looks like this:

<div class="typography">
$Title
   <% if Results %>
    <ul id="SearchResults">
<li>hrhrhr</li>
<li></li>
    </ul>
    <% else %>
    <p>No results found.</p>
    <% end_if %>
</div>


How can I call attributes of the dataobjects in the results template?

Avatar
Martijn

4 October 2009 at 1:04am Community Member, 271 Posts

<% control StudioSearchResults %>
<li> $StudioPostcode</li>
<% end_control %>

?

Neem een kijkje naar de Page_results.ss.. ehm
Take a look to the default Search method in the BlackCandy theme...

Avatar
baba-papa

4 October 2009 at 1:14am Community Member, 279 Posts

Thanks Martijn,

I simply forgot the <% control Results %>. Now I can access all dataobject properties. Thanks for your quick help.