CGBlog detail page with list of teasers

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
irish
Forum Members
Forum Members
Posts: 101
Joined: Tue Jun 03, 2008 2:31 pm

CGBlog detail page with list of teasers

Post by irish »

I want to add a list of five other blogs to the details page. So here is what I did:

1. Created a new summary template that only displays date and title of the blogs
2. added {CGBlog summarytemplate="tasters" pagelimit="5"} to details template

The five blog titles display fine but the actual main blog detail that should be displayed is incorrect. No matter which blog I select it will only display the fifth blog in my list. You can see what I mean here: http://dev.adikat.ie/en_IE/contact-us/adikat-blogs/ Select any blog and the details page will always display the same blog.
User avatar
M@rtijn
Power Poster
Power Poster
Posts: 706
Joined: Sat Nov 14, 2009 4:54 pm

Re: CGBlog detail page with list of teasers

Post by M@rtijn »

That's strange?!?

The title does change when you select a article, but the text in from another blogpost ???

I really don't see why this is happening, maybe you can post the CGBlog template's you are using?
irish
Forum Members
Forum Members
Posts: 101
Joined: Tue Jun 03, 2008 2:31 pm

Re: CGBlog detail page with list of teasers

Post by irish »

Thanks for the reply.

Code: Select all

<!-- Start CGBlog Summary Template "tasters" -->
{foreach from=$items item=entry}
<div class="CGBlogSummary">

{if $entry->postdate}
	<div class="CGBlogSummaryPostdate">
		<h3>{$entry->postdate|cms_date_format}</h3>
	</div>
{/if}
<div class="CGBlogSummaryLink2">
<h3><a href="{$entry->detail_url}" title="{$entry->title|escape:htmlall}">
{$entry->title|escape}</a></h3>
</div>

</div>
{/foreach}
<!-- End CGBlog Summary Template -->
And this is the Details template:

Code: Select all

<!-- Start CGBlog Details Template -->
{* set a canonical variable that can be used in the head section if process_whole_template is false in the config.php *}
{if isset($entry->canonical)}
  {assign var='canonical' value=$entry->canonical}
{/if}
{assign var='mytitle' value=$entry->title|escape}

<div id="otherblogs">
<h2>Other Blogs</h2>
{CGBlog  summarytemplate="tasters" pagelimit="5"}
</div>

<div class="sharearticles">
<h2>Share this Article</h2>
<!-- JS for social bookmarking  -->
</div>
<h2 id="CGBlogPostDetailTitle">{$entry->title|escape}</h2>
<hr id="CGBlogPostDetailHorizRule" />
{if $entry->categories}
<div class="CGBlogSummaryCategory">
{strip}{$category_label}
 {foreach from=$entry->categories item='category'}
   {$category.name} 
 {/foreach}
{/strip}
</div>
{/if}
{if $entry->postdate}
	<div id="CGBlogPostDetailDate">
		{$entry->postdate|cms_date_format} <br /> <br />
	</div>
{/if}
<div id="CGBlogPostDetailContent">
	{eval var=$entry->content}
</div>
{if $entry->extra}
	<div id="CGBlogPostDetailExtra">
		{$extra_label} {$entry->extra}
	</div>
{/if}
{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="CGBlogDetailField">
        {if $field->type == 'file'}
	  {* this template assumes that every file uploaded is an image of some sort, because CGBlog doesn't distinguish *}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}

{literal}<__script__ src="http://digg.com/tools/diggthis.js" type="text/javascript"></__script>{/literal}
<!-- End CGBlog Details Template -->
User avatar
M@rtijn
Power Poster
Power Poster
Posts: 706
Joined: Sat Nov 14, 2009 4:54 pm

Re: CGBlog detail page with list of teasers

Post by M@rtijn »

My first thought is that the CGblog call inside the detail page is the culprit. Clicking the link in the 5 teaser template doesn't seem to reload the entire page.

What happens if you move this piece of code to your page template instead of the detailtemplate?

Code: Select all

<div id="otherblogs">
<h2>Other Blogs</h2>
{CGBlog  summarytemplate="tasters" pagelimit="5"}
</div>
Another thought is playing around with the inline parameter on the call: {CGBlog summarytemplate="tasters" pagelimit="5" inline="0"} If this doesn't change things, make it inline="1".

EDIT: You have a double space in the call!
{CGBlog summarytemplate="tasters" pagelimit="5"}
{CGBlog summarytemplate="tasters" pagelimit="5"}
Make your community a better place!
irish
Forum Members
Forum Members
Posts: 101
Joined: Tue Jun 03, 2008 2:31 pm

Re: CGBlog detail page with list of teasers

Post by irish »

I tried adding the inline="1" and inline="0" it didn't make any difference. I just tried something else, I moved this code in the detail template to the bottom of the template. It works now but I can't get it to display on the top-right of the page. I tried using CSS but it's not co-operating.

Code: Select all

<div id="otherblogs">
<h2>Other Blogs</h2>
{CGBlog  summarytemplate="tasters" pagelimit="5"}
</div>
It looks like what was happening is that it was using the last blogpost from the 5 teasers as the main blog.
irish
Forum Members
Forum Members
Posts: 101
Joined: Tue Jun 03, 2008 2:31 pm

[Solved] CGBlog detail page with list of teasers

Post by irish »

Yaahoo, got it!

I used smarty's capture function to capture the main post first, ran the 5 teasers template and then displayed the main post.

Thanks for you help.

Code: Select all

{* set a canonical variable that can be used in the head section if process_whole_template is false in the config.php *}
{if isset($entry->canonical)}
  {assign var='canonical' value=$entry->canonical}
{/if}

{capture name='mainblog' assign="mainblog"}
{assign var='mytitle' value=$entry->title|escape}

<div class="sharearticles">
<h2>Share this Article</h2>
<!--  social marketing here -->

<h2 id="CGBlogPostDetailTitle">{$entry->title|escape}</h2>

<hr id="CGBlogPostDetailHorizRule" />

{if $entry->categories}
<div class="CGBlogSummaryCategory">
{strip}{$category_label}
 {foreach from=$entry->categories item='category'}
   {$category.name} 
 {/foreach}
{/strip}
</div>
{/if}
{if $entry->postdate}
	<div id="CGBlogPostDetailDate">
		{$entry->postdate|cms_date_format} <br /> <br />
	</div>
{/if}


<div id="CGBlogPostDetailContent">
	{eval var=$entry->content}
</div>

{if $entry->extra}
	<div id="CGBlogPostDetailExtra">
		{$extra_label} {$entry->extra}
	</div>
{/if}

{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="CGBlogDetailField">
        {if $field->type == 'file'}
	  {* this template assumes that every file uploaded is an image of some sort, because CGBlog doesn't distinguish *}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}


{literal}<__script__ src="http://digg.com/tools/diggthis.js" type="text/javascript"></__script>{/literal}

{/capture }

<div id="otherblogs">
<h2>Other Blogs</h2>
{CGBlog summarytemplate="tasters" pagelimit="5" inline="1"}
</div>

{$mainblog}

User avatar
M@rtijn
Power Poster
Power Poster
Posts: 706
Joined: Sat Nov 14, 2009 4:54 pm

Re: CGBlog detail page with list of teasers

Post by M@rtijn »

Cool!
Your link doesn't work anymore (http://dev.adikat.ie/en_IE/contact-us/adikat-blogs/), returns empty page. Did you move the blog elsewhere on the site? I would really like to see your end result (for future reference ;D )
Make your community a better place!
irish
Forum Members
Forum Members
Posts: 101
Joined: Tue Jun 03, 2008 2:31 pm

Re: CGBlog detail page with list of teasers

Post by irish »

working again
Post Reply

Return to “Modules/Add-Ons”