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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
atdesign
Forum Members
Forum Members
Posts: 38
Joined: Fri Feb 24, 2012 12:57 pm

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

Post 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.
Last edited by atdesign on Sat May 11, 2013 11:17 am, edited 2 times in total.
compufairy
Forum Members
Forum Members
Posts: 183
Joined: Sun Sep 07, 2008 10:47 am

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

Post by compufairy »

"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur..." (Red Adair)
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

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

Post 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
applejack
Power Poster
Power Poster
Posts: 1015
Joined: Fri Mar 30, 2007 2:28 am
Location: London

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

Post 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 !!!
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

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

Post by Wishbone »

Only if you want the GCB in the content... Won't work if it's a sidebar item.
applejack
Power Poster
Power Poster
Posts: 1015
Joined: Fri Mar 30, 2007 2:28 am
Location: London

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

Post 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.
uniqu3

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

Post 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.
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

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

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

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

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
atdesign
Forum Members
Forum Members
Posts: 38
Joined: Fri Feb 24, 2012 12:57 pm

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

Post 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}
Post Reply

Return to “CMSMS Core”