Template error upon page re-display

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
tomphantoo
Forum Members
Forum Members
Posts: 15
Joined: Mon Apr 11, 2011 7:33 am

Template error upon page re-display

Post by tomphantoo »

I surmise that non-cached UTD- and plugin-generated content cannot survive end-of-browser-session, and so page-re-display in a later session will always fail e.g. in the example below, how is smarty_cms_function_mobile_detect() supposed to re-run, unless the page is re-generated?

Should that function-call in the compiled template be replaced with the result of the call? But in that case, how does {nocache} work?

Any ideas about an effective (CMSMS and/or Smarty) solution ?

Example

template (extract):

Code: Select all

{nocache}{mobile_detect assign='is_mobile'}{/nocache}
{if $is_mobile}<meta name="viewport" content="width=device-width, initial-scale=1" />{/if}
compiles to (extract):

Code: Select all

<?php echo '/*%%SmartyNocache:95541818459d71d2b1c7e20_41875992%%*/<?php echo smarty_cms_function_mobile_detect(array(\'assign\'=>\'is_mobile\'),$_smarty_tpl);?>
/*/%%SmartyNocache:95541818459d71d2b1c7e20_41875992%%*/';?>
<?php if ($_smarty_tpl->tpl_vars['is_mobile']->value) {?><meta name="viewport" content="width=device-width, initial-scale=1" /><?php }
which works as expected when the page is first loaded.

However in a later session (i.e. after browser shutdown and restart, before forced page-reload):

Notice: Undefined index: is_mobile in <path to>/2c0abaecb4430a67290c234361796f895f9b3920_0.tpl_head.6.cache.php on line 37
Call Stack
# Time Memory Function Location
1 0.0122 344944 {main}( ) ../index.php:0
2 3.0261 15377552 Smarty_Internal_TemplateBase->fetch( ???, ???, ???, ??? ) ../index.php:161
3 3.0261 15377792 Smarty_Internal_TemplateBase->_execute( null, null, null, null, long ) ../smarty_internal_templatebase.php:107
4 3.0262 15395760 Smarty_Internal_Template->render( bool, long ) ../smarty_internal_templatebase.php:216
5 3.0265 15400464 Smarty_Template_Cached->render( object(Smarty_Internal_Template)[2972], bool ) ../smarty_internal_template.php:201
6 3.0266 15400512 Smarty_Internal_Runtime_UpdateCache->updateCache( object(Smarty_Template_Cached)[2975], object(Smarty_Internal_Template)[2972], bool ) ../smarty_template_cached.php:142
7 3.0267 15417760 Smarty_Template_Compiled->render( object(Smarty_Internal_Template)[2972] ) ../smarty_internal_runtime_updatecache.php:92
8 3.1042 15448216 Smarty_Template_Resource_Base->getRenderedTemplateCode( object(Smarty_Internal_Template)[2972], ??? ) ../smarty_template_compiled.php:172
9 3.1043 15448512 content_59d71d2b2d59a6_12582461( object(Smarty_Internal_Template)[2972] )
Post Reply

Return to “The Lounge”