开发者

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

开发者 https://www.devze.com 2023-02-08 16:53 出处:网络
I have a really strange problem with CMSMS - why the hell this is HALF-working: <head> {if $current_step==\'2\' or $current_step==\'4\'}

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_FAI开发者_StackOverflow中文版L
{/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.


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)


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


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

精彩评论

暂无评论...
验证码 换一张
取 消