Hello, I'm new to Umbraco, and woudl like ot know how to output the page id / name as a class on the <body> tag on each page of my site so i can apply different CSS to some pages.
I have read a few of ther similar posts on here, but i'm not sure where the different code goes - pls coud someone help!
If you can tell me which files to put the lines of code that would be amazing, just getting used to the structure of files after moving form usding Wordpress!
So if you have a setup with template inheritance, go to the developer section, under templates, find your body tag an add class, after that you can output the pageID or page name by usig this.
I'd recommend prefixing the pageID with some letters, since a CSS class name cannot (should not!) start with a number. So for example, a simple correction to Dennis's first example,
Output class on <body> tag from page ID / name
Hello, I'm new to Umbraco, and woudl like ot know how to output the page id / name as a class on the <body> tag on each page of my site so i can apply different CSS to some pages.
I have read a few of ther similar posts on here, but i'm not sure where the different code goes - pls coud someone help!
If you can tell me which files to put the lines of code that would be amazing, just getting used to the structure of files after moving form usding Wordpress!
Thanks in advance,
Lucy
Hi Lucy,
One way you could do output page ID / name in a class in the body tag, is by using umbraco item-element http://our.umbraco.org/wiki/reference/templates/umbracoitem-element
So if you have a setup with template inheritance, go to the developer section, under templates, find your body tag an add class, after that you can output the pageID or page name by usig this.
This gives you the pageID in the class
And the line here will give you the name of the page
or the id of the template that the page are using.
I hope this make sense to you if not just keep asking and I will try to help you.
/Dennis
Thank very much for this Dennis! - will try this now :)
I'd recommend prefixing the pageID with some letters, since a CSS class name cannot (should not!) start with a number. So for example, a simple correction to Dennis's first example,
Good luck!
is working on a reply...