Hi,
I am a new Modx user and so far really like it. I’ve searched the forums for a solution to my question, but didn’t find what I was looking for, so please forgive me if it does exist in the forums already:)
I would like to have a unique body ID <body id="whatever"> generated for each page in Modx. Then I can style the pages differently with CSS based on that ID. Is this something that is doable? If so, how?
Thanks in advance for any and all feedback!
Thnx!
Brian
-
MODX Staff
- 12,272 Posts
1) Create a TV called "bodyID" (or whatever) that’s assigned to all templates.
2) At Input Type: DropDown List Menu
3) Under Input Options:
inheritted==||Option 1 Text==opt1val||Opt 2 Text==opt2val||Opt 3==opt3val (and so on ...)
4) Under Default Value: @INHERIT
5) In your template:
<body id="[*bodyID*]">
Now you’ve got a handy set of default body ids to keep things consistent, and you only have to set the value at the top-most container document (it automatically will flow down to all it’s children).
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
Thanks, Rthrash! That’s exactly what I was looking for! However, being extremely new to this, I was hoping you could help just a bit more:) I created my template variable, but am unsure how to implement the input option values. I want the unique body id to be on every page created in my document tree. I can’t figure out how to take your example text below and use that syntax for my docs. Thanks again for your quick reply!
inheritted==||Option 1 Text==opt1val||Opt 2 Text==opt2val||Opt 3==opt3val (and so on ...)
Thanks, Opengeek! That’s exactly it. No TV required. I appreciate it. Thanks also to Rthrash for his solution!