Forum
Custom Page attribute
Hi, I have successfully set up a custom 'select' perch page attribute which selects a light or dark theme for the page:
In default.html:
<perch:pages id="bodyclass" type="select" label="Page look" options="Dark, Light" suppress="true" help="Decide if elements on the page will look Dark or Light. Change this if your header navigation isn't very clear."/>
In my php template:
<body class="<?php perch_page_attribute('bodyclass', array('template'=>'bodyclass.html')); ?>">
Here is the template bodyclass.html:
<perch:pages id="bodyclass" type="select" label="Page look" options="Light, Dark"/>
It works well, except when I create a new page, Light isn't selected so therefore not injected into the body class as a default value. This plays havoc with the layout as I am trying to hook into this class. Is there a way to force the value to be injected into the template upon saving the new page?
Thanks!
I have to go to the Page details, then save for the value to 'kick in'.
Use:
A ha! Thank you Drew.