Creating templates
NSM Body Class is intended to be used with an embedded "header" template.
- Create a new
_partialstemplate group and.headertemplate. - Add the
{exp:nsm_body_class}tag to the_partials/.headertemplate:<body {exp:nsm_body_class}> - Embed the
_partials/.headertemplate inside a primary template and add an embed parameter:{embed='_partials/.header' entry_id='10'} - Request the primary template in your browser and the html
<body>tag will look like:<body class='e-10'>
Adding a new key to the parameter map
In some cases you may want to add a new key to the parameter map. In the example below we'll extend the parameter map and add the "category" key.
Continuing from the example above add the parameter_map parameter to the {exp:nsm_body_class} tag in the _partials/.header template:
<body {exp:nsm_body_class parameter_map="category:cat"}>
Update the parent template to pass through the new category parameter:
{embed='_partials/.header' entry_id='10' category='cars'}
The HTML output will now look like:
<body class='e-10 cat-cars'>