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

Current position

Go to End

3 Posts   2437 Views


Community Member, 20 Posts

24 November 2006 at 3:51am

I base my templates on css, one element id in templates changes depending on sections of the site. I need custom function to return needed value of that id depending on where the user is. I'm aware of InSection() control but I want to do this in page controller to get cleaner code in template.

I've tried with function inside page_controller class but problem is that i can't access InSection() function from there. It seems to me that some part of the puzzle regarding page page_controller relation i don't understand right

Any hint regarding that or help with implementing required function will be appreciated. :)


Community Member, 27 Posts

24 November 2006 at 10:16am

Edited: 24/11/2006 10:23am

Controllers have fall back functions to call the same method (or variable) on the underlying dataobject, so it should call InSection() fine.

e.g In your controller, you could go:

is the same as calling

$page = $this->data()
return $page->InSection("home");

Perhaps your not in the controller, or your doing something else?

For more information about controllers, have a look at this:


Community Member, 20 Posts

27 November 2006 at 9:16pm

Thank you. I knew it must be something simple.