Jump to:

23456 Posts in 18905 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Control issue

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

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

Page: 1
Go to End
Author Topic: 890 Views
  • Terminator4
    Avatar
    Community Member
    81 Posts

    Control issue Link to this post

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

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Control issue Link to this post

    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.

    890 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.