Thanks Jo. I am understanding the issue more (I think) but am still not closer to a good fix.
I believe the issue I have is that once the smarty var is set in the parent template, it cannot be updated from a child template. Both for a varaible or an array element. Here are some more details:
page template (simplified):
Code: Select all
{process_pagedata}
{pageVars}{$pageVars=$pageVars scope=global}
{$testVar='test data from page template top' scope=global}
<!DOCTYPE html>
<__html lang="en">
<head>
{metadata}
</head>
</__body>
{Products}
<__body>
Tag: pageVars (simplified):
Code: Select all
function smarty_cms_function_pageVars ($params, &$tmp) {
$gCms = cmsms();
$smarty = $gCms->GetSmarty();
$pageVars['pageTitle'] = 'Default Page Title';
$pageVars['pageDescription'] = 'Default Page Description';
$smarty->assign( 'pageVars', $pageVars );
}
Products template (simplified):
Code: Select all
{$pageVars.pageTitle=$entry->product_name scope=global}{* does NOT work *}
{$pageVars.pageDescription=$entry->details|strip_tags|strip|truncate:150 scope=global}{* does NOT work *}
{$pageVars['TEST']='test data3 from Products' scope=global}{* does NOT work *}
{$testVar='test data from Products' scope=global}{* does NOT work *}
{$pageVars2=$pageVars scope=global}{* DOES work *}
{$testVarProducts='test data from Products' scope=global}{* DOES work *}
{* Note: only the 2 variables NOT previously set become available in metadata *}
metadata (simplified):
Code: Select all
<title>{$pageVars.pageTitle}</title>
<meta name="description" content="{$pageVars.pageDescription}" />
<!-- $pageVars is: {$pageVars|print_r}
$pageVars2 is: {$pageVars2|print_r}
$testVar is: {$testVar}
$testVarProducts is: {$testVarProducts}
-->
I now have a work around by testing for pageVars2 and overwriting PageVars, but this doesn't seem ideal, and I don't understand why I can't update a variable using scope=global?
Thanks