CMSMS("CMS Made Simple") user defined tags works only in <head> section?

2.5k views Asked by At

I have a really strange problem with CMSMS - why the hell this is HALF-working:

<head>
{if $current_step=='2' or $current_step=='4'}
HEAD_ON
{else}
HEAD_FAIL
{/if}
</head>
{if $current_step=='2' or $current_step=='4'}
NEITHER_ONE_OK
{else}
NEITHER_ONE_FAIL
{/if}
<body>
{if $current_step=='2' or $current_step=='4'}
BODY_OK
{else}
BODY_FAIL
{/if}
</body>

Returns:

HEAD_OK
NEITHER_ONE_FAIL
BODY_FAIL

I use latest CMSMS version - 1.9.3. And CMSMS is based on smarty, allowing to do this in CMSMS UDT section:

$gCms->smarty->assign('current_step',"".htmlspecialchars($_GET['step_id'])."");

I suppose this problem would be possible if CMSMS use some methodology which first interprets body section, then compiles UDT, and then compiles whole website.

Any solutions? Thank you.

3

There are 3 answers

0
ozzWANTED On BEST ANSWER

Answer from CMSMS dev team: "CMSMS (by default) processes the stuff above first, then the section, then the head section, and glues the results back together before output."

0
Thomas Hart On

CMSMS processes templates in an almost reverse order.

From the release notes for 1.4: http://www.cmsmadesimple.org/cgblog/818/Announcing-CMS-Made-Simple-1-4-Jamaica/

* We split the template into three pieces
a) Any text ontop of 
b) The section
c) the rest of the template (the body)
0
Guilherme Viebig On

Yes there is a solution.

You should capture the content part and other call with smarty to have variables available everywhere.

On the top of the template use:

{capture assign='cc'}{content}{/capture}

And replace the {content} tag for {$cc}

This way any variable define ina UDT call on a page content, after the head is processed will be available to the rest of the template.

Check this old guide to get some variable from body to head, you´ll understand how it works:

http://forum.cmsmadesimple.org/viewtopic.php?f=4&t=30475&sid=ed7e25c50612eb9f052ec4bee16d782c