[solved] V2 GCB not parsing Smarty code

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.
Locked
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

[solved] V2 GCB not parsing Smarty code

Post 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
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm

Re: V2 GCB not parsing Smarty code

Post 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 :)
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: V2 GCB not parsing Smarty code

Post 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.
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: V2 GCB not parsing Smarty code

Post by paulbaker »

That's great, thank you both for your help, now all sorted.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
Locked

Return to “CMSMS Core”