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.

Data Model Questions /

Pointing to the dataobject being displayed

Go to End

3 Posts   919 Views


Community Member, 48 Posts

2 July 2010 at 8:04pm

Edited: 02/07/2010 8:05pm

i have some dataobjects linked to page type. i display these objects in the template, performing a simple control nameoftheobjects, and displaying them.
and this works. while displaying them, i need to perform a control on them, like "if a certain dataobject field is equal to some value, return true."
I plan to do this creating a function in the page controller. but how i can point to the current dataobject being displayed?

<% control nameoftheobjects %>
<% if checkontheobjects %>
do somtehing with it
<% else %>
do something else with it
<% end_if %>
<% end_control %>


Community Member, 78 Posts

4 July 2010 at 9:08pm


In your example, <% control nameoftheobjects %> will iterate over the set of data objects. Within the <% control %> ... < % end_control %> structure, a reference to $foo is a reference to the foo propery or method on the current object. That is, inside the control loop, the default context changes to the data object being iterated, rather than the page. If `checkontheobjects` is a property or method of the data object, it is evaluated against the current data object being iterated, so that is probably exactly what you want.



Community Member, 48 Posts

4 July 2010 at 9:15pm

yeah, you're right, thanks! Calling a method created inside the php describing this dataobject allows you to have an "implicit" pointing to the object itself. Very useful thing: it's OO programming mindset after all. Thanks, now it works.