Jump to:

23552 Posts in 19349 Topics by 2891 members

General Questions

SilverStripe Forums » General Questions » Using Variable in loop after Up

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: 290 Views
  • tekilla83
    Avatar
    Community Member
    20 Posts

    Using Variable in loop after Up Link to this post

    Hi I try to do something like this in Template:

    <% loop getAllCategories %>
    <h1>$Category</h1> <!-- this is Correct -->
    <% loop Up.getFurnitureByCategory($Category) %>
    //content here
    <% end_loop %>
    <% end_loop %>


    In getFurnitureByCategory I don't get the Category, instead I get and string "$Category".

    I also tried escaping like {$Category}, but then I the braces are just part of my string.
    And $Me.Category didn't work either.

  • kinglozzer
    Avatar
    Community Member
    146 Posts

    Re: Using Variable in loop after Up Link to this post

    As soon as you use $Up, you take it out of the category scope, so you can't use $Category like that as it doesn't exist in your current scope.

    From what you're doing, I think you'd be better off using a GroupedList: http://doc.silverstripe.org/framework/en/howto/grouping-dataobjectsets

  • tekilla83
    Avatar
    Community Member
    20 Posts

    Re: Using Variable in loop after Up Link to this post

    Ahh ok, many thanks I'll have a look at this.

    Edit: cool thats pretty easy, works best many thanks again.

    290 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.