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.

General Questions /

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

if ClassName doesn't work with Controller


Reply


2 Posts   2167 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, 5513 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__;
}