Page 1 of 1

Allow editor to show/hide GCB on page? [SOLVED]

Posted: Thu May 02, 2013 1:13 pm
by atdesign
Hello,

I have a global content block for Facebook comments and I would like to allow the editor to control whether it shows on specific pages or not when editing page. Ideally via a checkbox.

How can I achieve this?
Thanks.

Re: Allow editor to show/hide GCB on page?

Posted: Thu May 02, 2013 2:25 pm
by compufairy

Re: Allow editor to show/hide GCB on page?

Posted: Thu May 02, 2013 3:26 pm
by Wishbone
uniqu3 posted a follow up to my article adding more flexibility:

http://www.i-do-this.com/blog/42/Give-Y ... ir-Sidebar

Re: Allow editor to show/hide GCB on page?

Posted: Fri May 03, 2013 12:13 am
by applejack
There is a far easier way to do this.

In TinyMCE Advanced Tab > Custom dropdown option

Then just add a line such as

Name whatever of my CGB|{global_content name=\'my_GCB\'}

In the profiles make sure you include customdropdown

Then when editing the page the client can choose it from the Custom Dropdown menu

Simplez !!!

Re: Allow editor to show/hide GCB on page?

Posted: Fri May 03, 2013 2:40 am
by Wishbone
Only if you want the GCB in the content... Won't work if it's a sidebar item.

Re: Allow editor to show/hide GCB on page?

Posted: Fri May 03, 2013 8:43 am
by applejack
Wishbone wrote:Only if you want the GCB in the content... Won't work if it's a sidebar item.
And the difference is ?

Using TinyMCE gives you the flexibility of having the CGB in any order you want and as many as you wish. Of course it depends on what type of content is contained in the CGB and formatting etc etc. At the end of the day depends on what one is trying to do and what you wish to allow a client to do or perhaps more appropriately not do.

Re: Allow editor to show/hide GCB on page?

Posted: Fri May 03, 2013 8:56 am
by uniqu3
@applejack
The difference is, that you control what client may choose.
I wouldn't recommend on following that article if one doesn't know what he/she is doing as article is old and needs an update.

But from Article that Wishbone linked that was a follow up on his original article a client would/was be able to choose and reorder GCB's no matter how many were added and with prefix you would determine which GCB's a client may see.

Re: Allow editor to show/hide GCB on page?

Posted: Fri May 03, 2013 2:50 pm
by Wishbone
It's also a bit of overkill for one content block. You can either used AdvancedContent or CGContentUtils to define the checkbox, then put an 'if' statement to check if it's checked, and then place the GCB if so.

Re: Allow editor to show/hide GCB on page?

Posted: Fri May 03, 2013 3:26 pm
by calguy1000
1. To allow a toggle of a specific GCB:

You could use CGContentUtils to create a checkbox content field. Then a simple if statement to enable it.

something like: (untested)
{content_module module=CGContentUtils block=toggle_gcb name='toggle_gcb' assign='myval'}
{if $myval != ''}{global_content name='foo'}{/if}

2. To allow a choice of 'pre-defined' GCB's:

You could use CGContentUtils to hardcode a list of GCB names into a dropdown box (with 'none' as one of the options)
Then a bit of smarty magic and it's done.

something like (untested)
{content_module module=CGContentUtils block=gcb_dropdown name='gcb_dropdown' assign='mygcb'}
{if $mygcb != '' && $mygcb != 'none'}
{global_content name=$mygcb}
{/if}

Hint: CGContentUtils will provide the basic tag you need to embed into your page template.

3. To not use any module at all,

if you wanted a simple toggle you could do something like:
{content block='toggle_gcb' label='Type anything here to enable the item in the sidebar' oneline='true' assign='toggle_gcb'}
{if $toggle_gcb != ''}{global_content name='foo'}{/if}

This provides a text field, the user can then just type anything into...the contents of this text field are not output, but it's non-empty status tells it to include the GCB.

Many ways to skin this cat... that's the power of CMSMS.

Re: Allow editor to show/hide GCB on page? [SOLVED]

Posted: Sat May 11, 2013 11:15 am
by atdesign
Thanks for all the suggestions everyone. With Wishbone's help, we implemented CalGuy's method.

{assign var='myval' value='hello'}
{content_module module='CGContentUtils' block='toggle_gcb' name='toggle_gcb' label='Facebook Comments' assign='myval'}
{if $myval != ''}
{global_content name='fbcomments'}
{/if}