[SOLVED] CGblog and category back button

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

[SOLVED] CGblog and category back button

Post by madsny »

hi.
im building a blog via CMSMS 1.7.1 and the CGblog module.

i wish to make a big button at the top of the page saying "go back to category list" which should jump back to the category for which x blog entry is connected to, even thou you might have visited the blog entry from an external link (meaning the browser back button would not be an option).

i've tried to wrap my head around this my failed, any good suggestion on how to do this ?.

it's not a problem getting the category name of the blog entry, but to build the actually link, since it seems to be using id's like this.
index.php?mact=CGBlog,cntnt01,default,0&cntnt01category_id=1&cntnt01returnid=58

hope some one can help.
thanks.
Last edited by madsny on Thu Jul 08, 2010 8:19 pm, edited 1 time in total.
JeremyBASS

Re: CGblog and category back button

Post by JeremyBASS »

So in times like this what you would want to do is use |print_r

I would think your in details right..
{$entry->categories|print_r} will print out from there..

Code: Select all

Array
(
    [category_id] => 24
    [name] => javascript
)
Array
(
    [category_id] => 23
    [name] => snippets
)
so really you should be able to grab that category_id and then it's just put it in the url.. hope that helps.. Cheers -Jeremy
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: CGblog and category back button

Post by madsny »

yes that does seem like a good idea hehe.. sadly there's no cleaver smarty trick for that hehe. i'll post my findings when if anyone should need the same assistance. :). thanks man :)
Last edited by madsny on Thu Jul 08, 2010 7:50 pm, edited 1 time in total.
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: CGblog and category back button

Post by madsny »

hmm can't seem to make it work properly..

if i call the {$entry->categories|print_r} i get the following:

Array
(
    [category_id] => 2
    [name] => flower
)

but if i then try to retrieve the category_id by doing this
{$entry->categories->category_id|print_r}

i get this "1" a number one where's the id is number 2... im a bit confused about this.

i also tried to access it via assigning the category array to a new variable, but with the same result.
{assign var='catArray' value=$entry->categories}
{$catArray->category_id}

another thins which puzzles me is, if i don't add the |print_r i won't get any values at all, i though that the smarty tag would print out any data in x array field.

what are my doing wrong. ?
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: CGblog and category back button

Post by madsny »

im a idiot sorry guy's :).
you access sub level Array like this.
{$entry->categories[0].category_id}

banging my head to the floor while feeling like a noob hehe
panthus

Re: CGblog and category back button

Post by panthus »

If I understand what you want to do correctly, I've found a way to do something like this.

The urls for the categories are only accessible with action="browsecat". If you want to access the urls in summary or detail view you can place a "ghost call" for browsecat on the same page, so that you can access the variable $categories.

Try this:

1. Create a new Category Template named "ghost" and delete everything from it, so it is completely empty.

2. Call the Summary and/or Detail view normally

Code: Select all

{CGBlog action="default"}
or

Code: Select all

{CGBlog action="detail"}
3. Place the ghost call somwhere on the same(!) page. It will not show anything on the front-end visually.

Code: Select all

{CGBlog action="browsecat" browsecattemplate="ghost"}
4. Put this in your Summary Template and/or Detail Template to show the category name(s) as a link

Code: Select all

{foreach from=$entry->categories item='category'}
{foreach from=$categories item='one'}
{if $one.name==$category.name}
<a href="{$one.url}">{$category.name}</a>
{/if}
{/foreach}
{/foreach}
I'm not really good with smarty yet, so I'm not sure if you really need two foreach loops or if it can be written another way...

You can see my version of it here: http://www.panthus-arts.de/development/blog.html
I have the category list visible in the sidebar, but with the empty template you can make it invisible.
Don't mind the chaotic/ugly styling, I'm only working on figuring out the functionality, the design work is done later...  ;D
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: [SOLVED] CGblog and category back button

Post by madsny »

:D that's a pretty nice idea, i really dislike hardcoding elements, by doing it the ghost page way you'll always get updated url, even if you would later move your blog to another archive or the like..
when i have some more time i'll see if i can get that to work :).
thanks man.
Post Reply

Return to “Modules/Add-Ons”