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


2 Posts   2015 Views

Ryan M.

2 March 2011 at 12:11pm Community Member, 309 Posts

I have an <% if ClassName = PhotoController %> in my top-level 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?


2 March 2011 at 10:17pm Forum Moderator, 5511 Posts

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