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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

Control scope


Go to End


21 Posts   7791 Views

Avatar
mallbeury

Community Member, 7 Posts

13 September 2008 at 11:29pm

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.

Avatar
Willr

Forum Moderator, 5523 Posts

13 September 2008 at 11:46pm

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

Avatar
mallbeury

Community Member, 7 Posts

15 September 2008 at 8:15pm

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

Avatar
Fuzz10

Community Member, 791 Posts

15 September 2008 at 9:47pm

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

That often makes the methods reachable ...

Avatar
mallbeury

Community Member, 7 Posts

15 September 2008 at 11:35pm

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

Go to Top