21301 Posts in 5735 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » Best way to insert "id" in template to identify each page uniquely for individual page styling...
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 281 Views |
-
Best way to insert "id" in template to identify each page uniquely for individual page styling...

9 November 2011 at 5:49pm Last edited: 9 November 2011 5:51pm
Hi,
I'm sure this has been done before or there might even be a standard way of doing this.
I'd like to have my main content div or even the body tag have a unique id for each page, so that I can selectively style elements differently on each page. (NOTE: the content I'd like to style is not editable in the CMS, so I can't add ID's via CMS editor)
eg For landing page
<body id="landing">
<h1>Landing Page Heading - Which I don't want to see...</h1>
...
</body>eg For contact us page
<body id="contactUs">
<h1>Contact Us</h1>
...
</body>CSS File
body#landingPage {
display:none;
}Rather than having to create a new field Page class, (ie ID), surely there is somefield available that will do the trick?
Thanks very much,
VWD.
-
Re: Best way to insert "id" in template to identify each page uniquely for individual page styling...

9 November 2011 at 6:58pm
Maybe use $ElementName? This is generated from the page's link.
-
Re: Best way to insert "id" in template to identify each page uniquely for individual page styling...

10 November 2011 at 7:09am
You can use $ID or $URLSegment too.
-
Re: Best way to insert "id" in template to identify each page uniquely for individual page styling...

10 November 2011 at 7:10am
Maybe even $ClassName if you can match against a general class of pages.
| 281 Views | ||
|
Page:
1
|
Go to Top |



