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, Ed, biapar, Willr, Ingo, swaiba

if ClassName doesn't work with Controller

Go to End

2 Posts   4399 Views

Ryan M.

Community Member, 309 Posts

2 March 2011 at 12:11pm

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?


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