How to link directly to multiple categories

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Like

Code: Select all

{if count($category_info) > 0}
You are in category restriction mode
{else}
You are browsing this page without category restrictions.
{/if}
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

garvinhicking wrote:

Code: Select all

{if count($category_info) > 0}
You are in category restriction mode
{else}
You are browsing this page without category restrictions.
{/if}
I'm using the original Mimbo code for this.

category view: in category restriction mode

Start page, single entry, tag pages, static pages, contact form, archives page, entries summary: without category restrictions

Edit: I forgot: I added your code to index.tpl. Should I retry it with the code added to the various .tpl files used for the start page columns?

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

I didn't have a look at your *.tpl files at all yet, so I can't comment on where you actually need to put that. :(

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
suntsu
Regular
Posts: 7
Joined: Tue Jan 29, 2008 8:54 am

Post by suntsu »

Hi there

Sorry for bumping this thread, but i've a question related to it.
If i select multiple categories via the categories plugin, it shows them correct with the url http://myblog/index.php?frontpage
But i would like to get an url like: http://myblog/index.php?serendipity[category]=1;2;3
The reason is that the users are able to create a bookmark to the categories they want.
Is there any way to do this?

thanks and cheers
manuel
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

For that, you can enable the "Smarty templating" option of the categories plugin, then edit your plugin_categories.tpl and change the POST method to GET; this should put everything into the URL bar to be able to bookmark that.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
suntsu
Regular
Posts: 7
Joined: Tue Jan 29, 2008 8:54 am

Post by suntsu »

Hi

Thanks for your answer.
It indeed shows the categorys in the link, but after that, content of all categorys is shown, even if only some are selected:
http://myblog/index.php?serendipity[mul ... ltiCat]=Go!
In other words, the filter doesn't work anymore after changing to GET

cheers
manuel
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, okay. Seems the serendipity code then checks on POST and not on GET.

Since usual FORM checkboxes only work as arrays and cannot append to a single variable, I think what you want to do is now possible this way.

You can do more tricky coding by writing smarty code that iterates the $categories arrays and create a link that users can bookmark; bookmarking the resulting page won't really work, as with all POSTed forms.

Another way would be to write a small event plugin that listens on the frontend_configure event hook, accepts the incoming GET data and autoconvert it to POST, so that s9y can operate on it.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
suntsu
Regular
Posts: 7
Joined: Tue Jan 29, 2008 8:54 am

Post by suntsu »

Hi,

An URL like http://myblog/index.php?serendipity[category]=1;2;3 would work, i have to try whether i can edit the plugin_categories.tpl in a way that it returns the URL like that.
But i am not sure about to have success, since i'm not familiar with php.
But thanks anyway for your help.

cheers
manuel
Post Reply