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

Displaying DataObject properties in a template


Go to End
Reply


3 Posts   2089 Views

Avatar
baba-papa

Community Member, 279 Posts

4 October 2009 at 12:41am

Edited: 04/10/2009 12:42am

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

Community Member, 271 Posts

4 October 2009 at 1:04am

<% 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

Community Member, 279 Posts

4 October 2009 at 1:14am

Thanks Martijn,

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