Page 1 of 1

Editor can select background color of page

Posted: Sat May 12, 2018 3:30 am
by carol1988
I'm creating a website and I want to give the page editors a dropdown selecting when they are editing a page where they can select the background color of that page. The selections should be : White, Grey, Transparent.

Can I add a dropdown selection in the page editor (TinyMCE).
carol

Re: Editor can select background color of page

Posted: Sat May 12, 2018 1:57 pm
by DIGI3
I'm not sure trying to do it within the wysiwyg content editor is best. There are two easy ways to do what you're wanting:

Use CGContentUtilities. Create a dropdown content block with your colour options and include it in your page template. Assign it to a variable, then use that variable to create a class. something like:

Code: Select all

{$background="{content_module module='CGContentUtils' block='color' label='Choose a background color'}"}
</__body class="{$background}">
OR

Use template inheritance, with three child templates containing just the necessary tag for changing the colour, e.g:

Code: Select all

{extends file='cms_template:YourMasterPageTemplate'}
{block name='bodytag'}
  </__body class="bgGrey">
{/block}
Using template inheritance is probably more efficient, but if you don't want to give editors the ability to change templates then the CGCU option may be better. Note: none of the above code is tested, and isn't complete - just gives you the idea.