3373 Posts in 998 Topics by 712 members
|Go to End|
2 July 2010 at 8:04pm Last edited: 2 July 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 %>
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.
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.
|Go to Top|