• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Related CGBlog Articles
PostPosted: Thu Jul 12, 2012 7:05 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 506
Location: Florida
In the footer of my blog posts, on the detail page I have listed the related articles based on help from this forum to not print out the current article in other places on my site I also have smarty stuff based on help from this forum, particularly Robert Campbell, so combining some stuff, this here trick does the following:

Puts a related list of articles at the bottom of your blog posts based on categories that the post is assigned to, multiple categories, AND if there are none, the header "Related Articles" and the accompanying html holding those links is not printed out.

First make a SUMMARY CBBlog template called "related" in this example:

\$1:
{assign var='currentitem' value=$entry->id}
{assign var='related1' value=0}
{foreach from=$items item=entry}
{if $entry->id !=$currentitem and $related1 == 0}
<section class="related clearfix"><h5>Related Articles</h5>
<ul>{assign var='related1' value=1}{/if}
{/foreach}

{foreach from=$items item=entry}
{if $entry->id !=$currentitem}
      <li>
         <a href="{$entry->detail_url}">
            {$entry->title|escape}
         </a>
      </li>
{/if}
{/foreach}

{assign var='related2' value=0}
{foreach from=$items item=entry}
{if $entry->id !=$currentitem and $related2 == 0}
</ul></section>
{assign var='related2' value=1}{/if}
{/foreach}


Next, in your DETAIL CGBlog template you will need to do put the following:

\$1:
{strip}{capture assign="categories"}{foreach from=$entry->categories item='one_category'}{foreach from=$categories item='one'}{if $one_category.name == $one.name}{$one.name},{/if}{/foreach}{/foreach}{/capture}{/strip}


This captures the categories for that blog Post and must come before the call to the related categories summary template

Then in the bottom of your blog DETAIL page as well, where you want the related categories to show up (if there are any), then paste the following. You will get a result like the screen shot (after applying your own css) IF there are related articles, but nothing if there are none.
\$1:
{CGBlog summarytemplate="related" category="$categories" number="6"}


Attachments:
Screen Shot 2012-07-12 at 2.58.06 PM.png
Screen Shot 2012-07-12 at 2.58.06 PM.png [ 91.89 KiB | Viewed 3047 times ]
Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Hosting Nation - Managed CMSMS Hosting