I'm (CMSMS newbie) preparing a new website and want to put Global content blocks on the side. However it seems that if you don't put any content into them, you cannot save them. I just want to put them in the design and prepare them so that an editor can add the content later, but when I want to save these blocks a message drops down from the top saying there is no content. The same happens when I want to delete existing content and save it as empty.
I've seen the code to add which make the blocks invisible if no content is present, but since CMSMS will not accept no content, I can't check to see that my code works.
[solved] Global content blocks no content can't be saved?
[solved] Global content blocks no content can't be saved?
Last edited by ozziejohn on Fri Jan 11, 2013 4:36 pm, edited 1 time in total.
Re: Global content blocks with no content cannot be saved?
I believe you are trying to use GCB's as Custom Content Blocks which are a bit different.
Global Content Blocks MUST have content. The point is to avoid to write the same Smarty code/template block repeatedly. The logic inside it can be whatever you want but not empty. A Custom Content Block is the same as the {content} except that it is customized. The main {content} has to exist on a template but can be empty, and all customized content blocks can also be empty.
Check this and this...
HTH.
Global Content Blocks MUST have content. The point is to avoid to write the same Smarty code/template block repeatedly. The logic inside it can be whatever you want but not empty. A Custom Content Block is the same as the {content} except that it is customized. The main {content} has to exist on a template but can be empty, and all customized content blocks can also be empty.
Check this and this...
HTH.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Global content blocks with no content cannot be saved?
I have the same issue. I get round this by setting the GCB to simply "-" when I don't want it to show.
This code in the template shows the GCB but hides it when the GCB is simply "-"
This code covers both scenarios where the GCB is saved as HTML or plain text.
This code in the template shows the GCB but hides it when the GCB is simply "-"
Code: Select all
{* Show UrgentMessageTop if required *}
{capture assign='UrgentMessageTop'}{global_content name='UrgentMessageTop'}{/capture}
{if $UrgentMessageTop|substr:0:1 ne '-' AND $UrgentMessageTop|substr:0:4 ne '<p>-'}
<div id="UrgentMessageTop">
{$UrgentMessageTop}
</div>
{/if}-
calguy1000
- Support Guru

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Global content blocks with no content cannot be saved?
One word, one answer:
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.
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.
Re: Global content blocks with no content cannot be saved?
Hi Paul.
Your code works like a charm
although I still have to go and check out the syntax to see what it means...
Thanks!
Your code works like a charm
Thanks!
Re: Global content blocks with no content cannot be saved?
Glad to help! Each line of code is:
Comment
Capture the GCB to a variable UrgentMessageTop
If first character is not equal to "-" AND first four characters are not equal to "<p>-" then
...Show DIV with GCB...
End if
@Calguy you mean set the GCB to be hard space? My non-technical clients would find that harder than just typing "-".
Comment
Capture the GCB to a variable UrgentMessageTop
If first character is not equal to "-" AND first four characters are not equal to "<p>-" then
...Show DIV with GCB...
End if
@Calguy you mean set the GCB to be hard space? My non-technical clients would find that harder than just typing "-".
Re: Global content blocks with no content cannot be saved?
Hi Paul.
Coming back to the code.
I understand the first condition, looking to see if "-" is present, but what is the reasoning behind the AND condition.
If you don't want to answer what probably are basic coding questions, don't worry about it. I've now got code that does what I want.
Thanks again Paul.
Coming back to the code.
I understand the first condition, looking to see if "-" is present, but what is the reasoning behind the AND condition.
If you don't want to answer what probably are basic coding questions, don't worry about it. I've now got code that does what I want.
Thanks again Paul.
Re: Global content blocks with no content cannot be saved?
If you have the HTML tick box checked when editing a GCB, it will (probably) add a <p> paragraph block around the "-" that is entered, so you have to check for that too.
So the "if" code shows the GCB UNLESS it starts with - or <p>-. Not sure if that is any clearer?
So the "if" code shows the GCB UNLESS it starts with - or <p>-. Not sure if that is any clearer?
Re: Global content blocks with no content cannot be saved?
Perfectly clear Paul, and thanks very much for your help!


