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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

comparing a dataobject variable to a dataobject-holder variable


2 Posts   516 Views


6 November 2013 at 8:19pm (Last edited: 6 November 2013 8:21pm), Community Member, 24 Posts

I am having a problem comparing a variable in a dataobject with a variable (one step up) in a productlisting page.

The variable in the product is called ProductCategory, and variable in the productlisting (or product holder) is called Category

I am actually using DataObjectAsPage module, but it is built on the dataobjectmanager.

function checkSomething(){
      if ($this->ProductCategory != $Top.Category) {
         return false;
      } else {
         return true;

then in the listing page I have <% if checkSomething %> which is inside the <% control %> loop for the products (on the product holder page)

Inside the control loop, in the .ss file I can print both these variables using $ProductCategory, $Top.Category
But not sure if Top is not working in the php file?
cant do an if statement right in the ss page, ss doesnt allow it?

Any help would be appreciated.


6 November 2013 at 9:05pm Community Member, 243 Posts

Template variables (and notation) are not valid on the controller our model in the same way.

Instead of $Top.Category try $this->Category()

The category is likely available on your controller as it is