Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Current position

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

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

Page: 1
Go to End
Author Topic: 1877 Views
  • Nemus
    Avatar
    Community Member
    20 Posts

    Current position Link to this post

    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.

  • Simon
    Avatar
    Core Development Team
    27 Posts

    Re: Current position Link to this post

    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:
    $this->InSection("home");

    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:
    http://doc.silverstripe.com/doku.php?id=designer-guide&s=controllers

  • Nemus
    Avatar
    Community Member
    20 Posts

    Re: Current position Link to this post

    Thank you. I knew it must be something simple.

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