Page 1 of 1
CGBlog: Category links on detail page with pretty URL's
Posted: Sat Feb 05, 2011 1:42 pm
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}
{/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
Re: CGBlog: Category links on detail page with pretty URL's
Posted: Sun Feb 06, 2011 4:54 pm
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>
{/if}
{/foreach}
{/foreach}
{/strip}
</div>
{/if}
Re: CGBlog: Category links on detail page with pretty URL's
Posted: Fri Oct 14, 2011 7:28 pm
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!
Re: CGBlog: Category links on detail page with pretty URL's
Posted: Sat Oct 15, 2011 1:59 am
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!!!!!!!!!!!!!!
Re: CGBlog: Category links on detail page with pretty URL's
Posted: Sun Oct 16, 2011 6:46 am
by carasmo
Anyone have an idea to print the name of the category above the listings? Thanks!
Re: CGBlog: Category links on detail page with pretty URL's
Posted: Sun Oct 16, 2011 7:08 am
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
on the page where the categories are listed in the param url thing. This works great. Use CSS to make title case or whatever.
Re: CGBlog: Category links on detail page with pretty URL's
Posted: Sat Jul 07, 2012 3:46 pm
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