Hi guys,
In my content template, I have the following defined:
{content_image block='hero_image' label='Hero Image' urlonly='1' exclude='thumb_' dir='images/parallax' assign='hero' scope=global}
In my head include file I have:
<meta property="og:image" content="{$hero|default:'/uploads/images/social_logo.png'}" />
It keeps showing the default, regardless. I have CGBlog and I have:
{if $entry->fieldsbyname.870x300}
{$hero="{$entry->file_location}/{$entry->fieldsbyname.870x300->value}" scope=global}
{/if}
That seems to work fine, but it doesn't work on my regular content pages. What did I miss?
Content block with scope global is not populating
Re: Content block with scope global is not populating
scope is a parameter of {assign}, not of all smarty tags.
Try:
Try:
Code: Select all
{content_image block='hero_image' label='Hero Image' urlonly='1' exclude='thumb_' dir='images/parallax' assign='hero'}
{$hero=$hero scope=global}
Re: Content block with scope global is not populating
Thank you velden, I placed it right underneath in my content template and it's still loading default. I tried this the other night after finding a blog sample, not sure what could be wrong. Does it matter that my <head> </head> code is in a different template...?velden wrote:scope is a parameter of {assign}, not of all smarty tags.
Try:
Code: Select all
{content_image block='hero_image' label='Hero Image' urlonly='1' exclude='thumb_' dir='images/parallax' assign='hero'} {$hero=$hero scope=global}
{content_image block='hero_image' label='Hero Image' urlonly='1' exclude='thumb_' dir='images/parallax' assign='hero'}
{$hero=$hero scope=global}
Re: Content block with scope global is not populating
It sure can matter. It should be noted that CMSMS processes and scopes variables based on three areas in the template. The </__body> and <head> tags are essential for that to work.Does it matter that my <head> </head> code is in a different template...?
https://cmscanbesimple.org/blog/base-cm ... d-metatags
https://docs.cmsmadesimple.org/configur ... processing
It's good practice to process the content blocks at the top of your page template, assign the output to a variable and give that variable a global scope.
Code: Select all
{content assign=main_content}{$main_content=$main_content scope=global}
<__html>
<head></head>
</__body>
{$main_content}
<__body>
</__html>
https://cmscanbesimple.org/blog/the-pow ... gn-manager