[SOLVED] CGBlog -> Detail Template + Pretty Urls

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
kidcardboard
Forum Members
Forum Members
Posts: 54
Joined: Mon Sep 28, 2009 5:25 pm

[SOLVED] CGBlog -> Detail Template + Pretty Urls

Post by kidcardboard »

So my problem is the detail template isn't being applied when pretty urls are being used. I've tried hardcoding it into .htaccess like so:

RewriteRule ^([0-9]*)/([0-9]*)/([0-9a-zA-Z\-]*).html$ index.php?mact=CGBlog,cntnt01,detail,0&cntnt01articleid=$1&cntnt01detailtemplate=blog_detail&cntnt01returnid=$2 [NC,L]

with no joy(with or without that line). I know with the News module the the url would've been something like:

"http://www.mysite.com/news/1/34/news-it ... te-id.html

but I don't see that behavior with the CGBlog module. Am I doing something wrong or is that just not a feature of the current release?
Last edited by Dr.CSS on Fri Feb 17, 2012 4:51 pm, edited 2 times in total.
Reason: Please use double quotes on fake links so they aren't clickable...
kingmadw
New Member
New Member
Posts: 2
Joined: Tue Jul 26, 2011 12:22 am

Re: [SOLVED] CGBlog -> Detail Template + Pretty Urls

Post by kingmadw »

How did you eventually solve this?
dazzyweb
Forum Members
Forum Members
Posts: 29
Joined: Mon May 30, 2011 1:21 pm

Re: [SOLVED] CGBlog -> Detail Template + Pretty Urls

Post by dazzyweb »

I also have a problem applying a detail template

Did anyone resolve this?
DiH
Forum Members
Forum Members
Posts: 14
Joined: Thu Nov 11, 2010 12:30 pm

Re: [SOLVED] CGBlog -> Detail Template + Pretty Urls

Post by DiH »

The only way I managed to solve it, was to make a few if statements in the default template, and then just paste template layout inside the if block, thus creating monstrously huge and messy template file. Yet, it works.

Would be great to finally have it fixed in the module itself.
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: [SOLVED] CGBlog -> Detail Template + Pretty Urls

Post by psy »

Had the same issue and my solution was similar but needs less coding in the summary template.

It checks the URL to see if the blog prefix that I entered in the Options tab exists. If so, it means that I need a detail template.

The following code then explodes the {$cgsimple->self_url()} string into an array based on the '/' character. I then count the number of array items to find the article id and finally call the detail template with this id.

NB: You need to put the ending {/if} just before the last {/if} in the summary template to close the statement and have CGSimpleSmarty installed.

At the top of the Summary template:

Code: Select all

{if count($items) ne 0}
{if $cgsimple->self_url()|strpos:'blog' !== false}
{assign var=x value="/"|explode:$cgsimple->self_url()} 
{CGBlog action=detail articleid=$x.4}
{else}
{* rest of normal summary template *}

{/if}
hth
psy
surogat
Forum Members
Forum Members
Posts: 52
Joined: Sun Jan 27, 2008 6:14 pm

Re: [SOLVED] CGBlog -> Detail Template + Pretty Urls

Post by surogat »

Im not sure that i understood you coretctly,
my summary page looks like this;

Code: Select all

{if count($items) ne 0}
{if $cgsimple->self_url()|strpos:'blog' !== false}
{assign var=x value="/"|explode:$cgsimple->self_url()}
{CGBlog action=detail articleid=$x.4}
{else}
{* rest of normal summary template *}

<div class="pero">
{foreach from=$items item=entry name="newsentry"}
<a href="{$entry->detail_url}" title="{$entry->title|cms_escape:htmlall}">
<h2>{$entry->title|cms_escape}</h2>
{assign var=post value=$entry->id}
{assign var=img value=$entry->sliderbig}  
<div class="summaryimage">{if isset($entry->fieldsbyname.sliderbig)}
{supersizer path="uploads/news/id$post/$img" height=250 alt=$entry->title|cms_escape:htmlall}{/if}
</div>
</a>
{/foreach}
</div>
{/if}{/if}
But detailtemplate is not apllied..
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: [SOLVED] CGBlog -> Detail Template + Pretty Urls

Post by psy »

In short, the code takes the pretty URL, splits it into an array based on the '/' character and assigns it to $x.

Sample URL: "http://mysite.com/blog/39/My-Article-Name.html

Things to check:

1. The text to search is called '/blog/'. Change the string to whatever you've called it in the options
2. The index number in the $x array of the article id is 4. Print out the $x array to confirm you are getting the correct item. Using the above URL, the array would look like:

Code: Select all

x = Array
  [0] = 'http'
  [1] = ''
  [2] = 'mysite.com'
  [3] = 'blog'
  [4] = 39
  [5] = 'My-Article-Name.html'
So we call $x.4 when we need the article id.

The same thing works when you need to list a particular category, eg:

Sample URL: "http://mysite.com/blog/category/19/General.html

Code: Select all

{assign var=x value="/"|explode:$cgsimple->self_url()} 
{if $cgsimple->self_url()|strpos:'/category/' !== false}
{cms_module module=CGBlog action=default category_id=$x.5 showall=1 summarytemplate=summary-by-category}


In this case the search string is '/category/' and the category id number, 19, is stored in $x.5

Also, in the past I've found sometimes calling a module within another module template does not work when you use the shorter plugin version, eg {CGBlog}. Use the full {cms_module module=CGBlog ...} tag instead. Not sure this is still relevant with 1.10+ but worth a try.

Hope this helps
psy
Post Reply

Return to “Modules/Add-Ons”