Page 1 of 1

[solved] V2 GCB not parsing Smarty code

Posted: Wed Nov 11, 2015 2:51 am
by paulbaker
Version 2.0.1.1, installed direct (not upgraded).

I have set up a global content block GCB as described in the "CUSTOMER EDITABLE GCB'S" section of
http://docs.cmsmadesimple.org/introducing-cmsms-2-0
(towards the bottom).

In my "GCB" (which is a footer div) I want a second class to show on the home page, so I added:

Code: Select all

<div class="row rowfooter {if $page_alias == 'home'} rowfooterhome {/if} ">
This would work fine in V 1.x. However in V 2 it is not parsing the smarty, I am seeing the "{if $page_alias == 'home'}"...in the generated HTML.

I have searched the forum, but perhaps not using the right keywords.

What am I doing wrong? :-\

Thanks

Re: V2 GCB not parsing Smarty code

Posted: Wed Nov 11, 2015 2:34 pm
by scooper
You'll need to use eval if you want to parse smarty in your GCB.

calguy posted this example over here

Code: Select all

{page_attr page='global-content' key='footer' assign=tmp}{* get the contents of this block into the smarty variable $tmp *}
{eval var=$tmp}{* treat the smarty variable $tmp as a template *}
See - I told you GCBs are a pain in 2.0 :)

Re: V2 GCB not parsing Smarty code

Posted: Wed Nov 11, 2015 5:31 pm
by velden
See - I told you GCBs are a pain in 2.0 :)
First I must admit I didn't use it much yet.
But... if you're using code like that in the 'GCB V2' I think you're doing something wrong.

The 'GCB V2' alternative is meant for user editable content. I doubt a user (editor) will/should add the {if}...{/if} code. If you're building a footer for general use in multiple template consider building it as a separate template (in stead of 'GCB V2') or think of template inheritance.

Inside those templates one could use the user editable attributes from a 'GCB V2' like e.g. a phone number, address details and such.
Imagine how cool that could be: an editor only needs to enter the minimum required information. Should not care about a line-break or font-style or.... Serve him one page with content blocks for stuff you (as a designer/developer) want to be filled. Likely it doesn't need any wysiwyg stuff. Only oneline content blocks. Or perhaps a color picker, or a checkbox or a dropdown (might need 3rd party module).

The main reason the old GCBs are now templates is because many of them ARE actually templates.

Re: V2 GCB not parsing Smarty code

Posted: Wed Nov 11, 2015 5:38 pm
by paulbaker
That's great, thank you both for your help, now all sorted.