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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Control issue


Go to End


2 Posts   1557 Views

Avatar
Terminator4

Community Member, 81 Posts

28 February 2009 at 1:41am

If I have Categories and Products and I perform a control to get all the Products in a Category and I want to be able to access the Page_Controller of the Products in the Category page. How would I do it?

Example:

<% control getProducts %>
$ID : $Title
$Top.MyCategoryFunction
$MyProductFunction

<% end_control %>

Avatar
Carbon Crayon

Community Member, 598 Posts

1 March 2009 at 11:30pm

If you are on any other page to a CategoryPage try putting a 'GetCategory()' function in your ProductPage model so that you can return the category page from within a control block. You still won't be able to access the CategoryPage_Controller though, so put the functions you need to access into the model class. Then you could do something like this:

<% control GetProducts %>
$ID:$Title
$GetCategory.CategoryModelFunction
$MyProductFunction

<% end_control %>

If you are on a Category page then $Top.CategoryFunction should work fine.