Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » if ClassName doesn't work with Controller

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: 1785 Views
  • Ryan M.
    Avatar
    Community Member
    309 Posts

    if ClassName doesn't work with Controller Link to this post

    I have an <% if ClassName = PhotoController %> in my top-level Page.ss template file, to include some js on a certain class. However I'm not using page types, only the controller (PhotoController extends Page_Controller). The if ClassName seems to work only on page types, not the controller. Can anyone shine some light on this?

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: if ClassName doesn't work with Controller Link to this post

    Yes because $ClassName is tied to a SiteTree model (like $Title), you could create a ClassName function on your controller like..

    function ClassName() {
    return __CLASS__;
    }

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