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

Adding CSS Class to CMS Root div

Go to End



Community Member, 5 Posts

3 September 2012 at 7:36pm

I need to add a css class to the main #Root window of the CMS, which ideally could be custom controlled by the Page classes, but at the very least that reflects the PHP Class name that is being edited.

For example.

I have a custom php class called ArticlePage, it extends Page. I have added a custom field called YouTube Code, I want to be able to style the edit field for "YouTube Code" *just in on the ArticlePage edit pages*. So if I had a ReviewPage that also had a YouTube Code field, my css wouldn't affect it.

So in other words, if I could find a way to add a class called "ArticlePage" to the div with id "Root_Main" then I could write CSS that would achieve this.

Is this possible?

I have found the CMSTreeClasses() method on SiteTree; this is similar to what I want to do, but different. This lets me style the individual items in the Site Tree hierarchy. I want to add a class to the edit fields container itself.