CGBlog: Category links on detail page with pretty URL's

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
rick1980
New Member
New Member
Posts: 7
Joined: Fri Feb 04, 2011 7:15 pm

CGBlog: Category links on detail page with pretty URL's

Post by rick1980 »

Hi,

I have this problem with pretty URL's and detail page of CGBlog. A great feature is to make the category items linkable of an article. I did this by doing the following (with the help of this forum).

Code: Select all

{if $entry->categories}
<div class="CGBlogSummaryCategory">
{strip}
 {foreach from=$entry->categories item='one_category'}
  {capture assign='urlparam'}&category={$one_category.name}{/capture}
  {cms_selflink page='categorie' urlparam=$urlparam text=$one_category.name|strtoupper}&nbsp;
 {/foreach}
{/strip}
</div>
{/if}


The lading page is

Code: Select all

{CGBlog category=$smarty.get.category detailpage=$pagealias}
This works fine, but only with ugly URL's and not with pretty urls. The browsecat page has the ability to use pretty urls.

Code: Select all

{foreach from=$categories item='one'}
<a href="{$one.url}" title="{$one.name}">{$one.name}</a>
{/foreach}
It is possible to link the category url somehow (one.url) with the '$entry->categories' stuff.

Thank you.

- Rick
rick1980
New Member
New Member
Posts: 7
Joined: Fri Feb 04, 2011 7:15 pm

Re: CGBlog: Category links on detail page with pretty URL's

Post by rick1980 »

Hello,

I solved it!

For people who want to use pretty url's see following code.

Code: Select all

{if $entry->categories}
<div class="CGBlogSummaryCategory">
{strip}
 {foreach from=$entry->categories item='one_category'}
	{foreach from=$categories item='one'}
		{if $one_category.name == $one.name}
 			<a href="{$one.url}" title="{$one.name}">{$one.name|strtoupper}</a>&nbsp;
		{/if}
	{/foreach}
 {/foreach}
{/strip}
</div>
{/if}

carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm

Re: CGBlog: Category links on detail page with pretty URL's

Post by carasmo »

I put this on the detailtemplate in the cgblog:

Code: Select all

{if $entry->categories}
<li class="categories">
{strip}
{foreach from=$entry->categories item='one_category'}
   {foreach from=$categories item='one'}
      {if $one_category.name == $one.name}
         <a href="{$one.url}" title="{$one.name}">{$one.name|strtoupper}</a> 
      {/if}
   {/foreach}
{/foreach}
{/strip}
</li>
{/if}
And nothing shows up in the category list when I look at the blog post. What am I doing incorrectly? Thanks!
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm

Re: CGBlog: Category links on detail page with pretty URL's

Post by carasmo »

I didn't get this to work but this in both my summary and detail templates:

Code: Select all

{foreach from=$entry->categories item='one_category'}
{capture assign='urlparam'}?&category={$one_category.name}{/capture}
{cms_selflink page='cats' urlparam=$urlparam text=$one_category.name}<br/>
{/foreach}
along with a detail page called "cats"

with this:

Code: Select all

{CGBlog category=$smarty.get.category detailpage=$pagealias}
on it did the trick it returns: cats.html?&category=test category and works great!!!!!!!!!!!!!!
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm

Re: CGBlog: Category links on detail page with pretty URL's

Post by carasmo »

Anyone have an idea to print the name of the category above the listings? Thanks!
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm

Re: CGBlog: Category links on detail page with pretty URL's

Post by carasmo »

I created a UDT called catname

Code: Select all

$uri = $_SERVER['REQUEST_URI'];
$tmp = explode('/', $uri);
$tmp = explode('?', $uri);
$tmp = explode('&', $uri);
$tmp = explode('category=', $uri);
$param = end($tmp);
echo $param;
Probably a shorter way to write this since I'm not a php person. Then put

Code: Select all

{catname}
on the page where the categories are listed in the param url thing. This works great. Use CSS to make title case or whatever.
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm

Re: CGBlog: Category links on detail page with pretty URL's

Post by carasmo »

This top post leaves something out. In order for the pretty url to work, the browsecategory call must be on the page, if you want, see how I did it here:

http://forum.cmsmadesimple.org/viewtopi ... 09#p282009
Post Reply

Return to “Modules/Add-Ons”