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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

if ClassName doesn't work with Controller


Go to End


2 Posts   5402 Views

Avatar
Ryan M.

Community Member, 309 Posts

2 March 2011 at 12:11pm

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?

Avatar
Willr

Forum Moderator, 5523 Posts

2 March 2011 at 10:17pm

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__;
}