Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Control scope

Our old forums are still available as a read-only archive.

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

Page: 1 2 3
Go to End
Author Topic: 6714 Views
  • mallbeury
    Avatar
    Community Member
    7 Posts

    Re: Control scope Link to this post

    Hi, we have version 2.2.2 and $Top does not seem to do anything. Can you confirm it still works?

    We're trying to build a pretty in depth site (http://fiction.previews.umguk.vvhp.net/staging/) but without $Top working we're a little stuck.

    This is an example that does not work:

    $Title
    <% control Menu(1) %>
    <% control children %>
    $Top.Title
    <% end_control %>
    <% end_control %>

    The $Top.Title displays nothing.

    Hope you can help.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Control scope Link to this post

    Maybe $top is in trunk or removed.. you can do <% control Level(1) %>$Title<% end_control %. to get the topmost then

  • mallbeury
    Avatar
    Community Member
    7 Posts

    Re: Control scope Link to this post

    Thanks for such a speedy reply, that does indeed allow me to reference built in values.

    I was hoping it would give me the context of the ContentController, so I can call functions.

    I'm trying to call functions as I would normally do before entering into the scope of a 'control', but it seems this is only possible before you use a 'control' block.

    Is there another way I can reference functions of the ContentController once we're inside a 'control'? This is really important to the sites we build and severely limiting if this is not possible.

    Matt

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: Control scope Link to this post

    try placing your functions in the Page class instead of the controller class.

    That often makes the methods reachable ...

  • mallbeury
    Avatar
    Community Member
    7 Posts

    Re: Control scope Link to this post

    Aha, have got the $Top working! I just downloaded the latest nightly build and it works as I'd hoped, hoorah!

    I was relying on the latest stable build 2.2.2 which it seems has lost that feature.

    Thanks

    Matt

    6714 Views
Page: 1 2 3
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.