[SOLVED] content not loading with smarty cache enabled

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.
Post Reply
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

[SOLVED] content not loading with smarty cache enabled

Post by rotezecke »

After the upgrade from 1.10.3 to 1.11 i have a problem on two templates that use multiple content blocks that are wrapped in an if statement:

Code: Select all

{content block="tab_one" label="Title for 1st tab" assign=tab_one oneline="true"}
{if !empty($tab_one)} <div class="pane" id="pane1"> {content block="pane_one" label="Content for 1st pane"}</div> {/if}

{content block="tab_two" label="Title for 2nd tab" assign="tab_two" oneline="true"}
{if !empty($tab_two)} <div class="pane" id="pane2">{content block="pane_two" label="Content for 2nd pane"}</div> {/if}

and so on.
however, with [edit] smarty [end edit] caching enabled, anything wrapped in these type of if statements don't load. (view page source - content not there). browser thinks page loaded successfully. when I disable the if statement things work/load fine. Is there a syntax error in the if statement?

EDIT: I tried empty() with not and !, then tried different styles of qualifiers (!= ne neq) '' (leaving spaces on either side). still no luck.

Edit: 1.10.3 defined IF_FUNCS in
/lib/smarty/Smarty.class.php

Code: Select all

    var $security_settings  = array(
                             'PHP_HANDLING'    => false,
                             'IF_FUNCS'        => array('array', 'list',
                                                               'isset', 'empty',
                                                              'count', 'sizeof',
                                                            'in_array', 'is_array',
                                                          'true', 'false', 'null'),
                                 'INCLUDE_ANY'     => false,
                                   'PHP_TAGS'        => false,
                                'MODIFIER_FUNCS'  => array('count'),
                                  'ALLOW_CONSTANTS'  => false,
	                                    'ALLOW_SUPER_GLOBALS' => true
                                  );
1.11 does not. Relevant?

Cheers, Mario

CMSMS 1.11
CMSMailer 5.2.1
FileManager 1.4.0
MenuManager 1.8.2
ModuleManager 1.5.5
News 2.12.7
Search 1.7.6
TinyMCE 2.10.1
CGSimpleSmarty 1.5.2
CGExtensions 1.30
CGBlog 1.9.8
CGFeedback 1.5.7
Captcha 0.4.5
FormBuilder 0.7.3
IE6Warning 1.03
Showtime 3.2
CMSPrinting 1.0.2

Server: Linux Debian Lenny 2.6.26-1-686 kernel
apache 2.2.9-10
mysql 5.0.51a-24
php 5.2.6-1
Last edited by rotezecke on Thu Aug 09, 2012 4:30 am, edited 3 times in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: content not loading with smarty cache enabled

Post by calguy1000 »

Do you mean the 'Enable Smarty Caching' checkbox on the "Smarty Settings" tab of the "Global Settings" page?
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.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: content not loading with smarty cache enabled

Post by rotezecke »

Yes, Site Admin -> Global Settings -> Smarty Settings

When "Enable Smarty Caching" is set to "Yes" the content does not load. (I tried all other possible combinations of the three settings below). I also removed many if not most plugins, global content, and what not from my template to see if it makes a difference and also tried nocache here and there.

http://forum.cmsmadesimple.org/viewtopi ... 8&p=283831

Here's a similar report, but in my case removing the if statement from around the additional content blocks, fixes it. (But of course, i'd like to keep my if statements). All other if statements work fine.

Setting "Enable Smarty Caching" to "No" also works (content is loaded).
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: content not loading with smarty cache enabled

Post by calguy1000 »

I just tested this, and it is correct. With Smarty caching enabled the compiled/cached php code will not have the logic to hide the output...

Solution Surround your logic with {nocache} and {/nocache}
i.e:

Code: Select all

{nocache}
{content block='Sidebar' assign='tmp'}
{if $tmp != ''}
  <div id="sidebar">
  {$tmp}
  </div>
{/if}
{/nocache}
Edit: More information here: http://docs.cmsmadesimple.org/general-i ... g-in-cmsms
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.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: content not loading with smarty cache enabled

Post by rotezecke »

Thanks heaps. Works fine now.
cypher6x
Forum Members
Forum Members
Posts: 13
Joined: Mon Jul 09, 2012 11:27 am

Re: [SOLVED] content not loading with smarty cache enabled

Post by cypher6x »

Does the assign have to be wrapped in the {nocache} as well or just around the {if} construct?

I tend to have all my assigns at the top of the template and logic further down the page.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [SOLVED] content not loading with smarty cache enabled

Post by calguy1000 »

I am not sure. I would tend to think (based on my knowledge of smarty) that it has to be around the logic.
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.
Post Reply

Return to “CMSMS Core”