Meta descriptions from CGBlog through VAR field
Posted: Wed May 02, 2018 11:25 am
Hi,
I have the need for specific meta descriptions for each of my pages for the CGBlog pages.
I have created a new public field called description.
When referencing this in the template to check if all text inputs are displaying correctly, it works, with the statement
So that is ok, but based on trying to create global var at the bottom of the template,
Here is my main page template,
Any help on why that last meta tag bit at the end is not working would be muchly appreciated... not quite sure where I've gone wrong, especially because I did EXACTLY the same thing for the title...
Ta,
Jake
I have the need for specific meta descriptions for each of my pages for the CGBlog pages.
I have created a new public field called description.
When referencing this in the template to check if all text inputs are displaying correctly, it works, with the statement
Code: Select all
{if isset($entry->fields)}
{foreach $entry->fields as $field}
<div class="CGBlogDetailField">
{if $field->type == 'image'}
<img src="{$entry->file_location}/{$field->value}"/>
{else}
<p>{$field->value}</p>
{/if}
</div>
{/foreach}
{/if}
Code: Select all
{assign var="description" value=$field->description|escape scope=global}
Code: Select all
{if isset($description)}
<meta name="description" content="{$description}">
{else}
<meta name="description" content="Insert regular meta desc here...">
{/if}

Ta,
Jake