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


3 Posts   1897 Views


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


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">
   <% if Results %>
    <ul id="SearchResults">
    <% else %>
    <p>No results found.</p>
    <% end_if %>

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


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

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


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


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.