CGBlog summary template categories
Posted: Sun Jul 12, 2020 9:39 pm
I'm using CGBlog and in the summary template I want to to ad a rule that if a category is 'Social Media' then it should go to an external link (which I can add) and not link to the content.
Ok this works but it's not right because, if the blog entry has more than one category then it duplicates them. See attached at the bottom "RV JAZZ BIG BAND" with 2 images.
So it's the "foreach from=" I need help with.
Here's the bit of code from the template I'm having problems with.
Ok this works but it's not right because, if the blog entry has more than one category then it duplicates them. See attached at the bottom "RV JAZZ BIG BAND" with 2 images.
So it's the "foreach from=" I need help with.
Here's the bit of code from the template I'm having problems with.
Code: Select all
{if $entry->categories}
{foreach from=$entry->categories item='category'}
{if $category.name == 'Social Media'}
<div class="CGBlogSummaryLink">
<h4>{$entry->title|escape}</h4>
</div>
{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}
<div class="CGBlogSummaryField">
{if $field->type == 'image_select'}
<img src="{CGSmartImage notag="1" src="{uploads_url}/{$field->value}" filter_croptofit="330,330,c"}"/>
{else}
{$field->name}: {eval var=$field->value}
{/if}
</div>
{/foreach}
{/if}
{else}
<div class="CGBlogSummaryLink">
<h4><a href="{$entry->detail_url}" title="{$entry->title|escape:htmlall}">{$entry->title|escape}</a></h4>
</div>
{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}
<div class="CGBlogSummaryField">
{if $field->type == 'image_select'}
<a href="{$entry->detail_url}" title="{$entry->title|escape:htmlall}">
<img src="{CGSmartImage notag="1" src="{uploads_url}/{$field->value}" filter_croptofit="330,330,c"}"/>
<span class="image-overlay">
<span class="overlay-icon"><i class="fa fa-file-text"></i></span>
</span>
</a>
{else}
{$field->name}: {eval var=$field->value}
{/if}
</div>
{/foreach}
{/if}
{/if}
{/foreach}
{/if}