Page 1 of 1
Only display certain categories
Posted: Sun Feb 06, 2005 10:48 pm
by Guest
I'd like to make it that only certain categories posts show up on the main site, and to restrict others to only show when the category is accessed from the menu. Is this possible through modifications or some sort of plugin?
Thanks.
Re: Only display certain categories
Posted: Sun Feb 06, 2005 11:16 pm
by garvinhicking
Yes, this can be done with a plugin solution.
But the easiest way is to set a fixed category for the mainpage to be displayed.
Edit your index.php and enter the line
$serendipity['GET']['category'] = '5';
Instead of 5 use the category id you want to be shown on the mainpage. Then your visitors must access the category list to view other categories.
As you can post to multiple categories, you can assign every entry for the mainpage category to (also) show up there.
Regards,
Garvin
Not Working
Posted: Mon Feb 07, 2005 12:09 am
by Guest
Hi, thank you for such a quick reply. I've been trying to get this solution to work, but I'm having a hard time.
I'm not sure where this is supposed to be added/edited, so if you could clarify that I'd really appreciate it. I've tried editing a few lines that look similar and also adding the line you mentioned but simply modifying the category number to no avail.
Re: Not Working
Posted: Mon Feb 07, 2005 2:49 pm
by garvinhicking
I'd need to know which Serendipity version you're running? Then I can give you more detailed instructions...
Regards,
Garvin
Versions
Posted: Mon Feb 07, 2005 9:33 pm
by Guest
I'm using yesterdays CVS (s9y_200502061337.tar.gz) 0.8 development version. I suppose it'd be better to use the stable version though, right? I'm just used to the open source community treading very carefully with their versions, most development versions in my experience have been release quality, it just seems like developers are being careful. So far, this has been the case with the development snapshot (or so I've found, it's quite stable) as well. Kudos to you on that.
However, If it'll work better on a previous release, please direct me to which would be best.
Thanks, your help is much appreciated.
Re: Versions
Posted: Wed Feb 09, 2005 12:16 pm
by garvinhicking
Hi!
In fact you're doing the right thing - latest CVS is always better for us to tell you about.
Now, just open your index.php file of Serendipity. Go to line 293. There you should see this line:
Code: Select all
if ($serendipity['GET']['action'] == 'search') {
$serendipity['uriArguments'] = array(PATH_SEARCH, urlencode($serendipity['GET']['searchTerm']));
} else {
$serendipity['uriArguments'][] = PATH_ARCHIVES;
}
include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
change that to:
Code: Select all
if ($serendipity['GET']['action'] == 'search') {
$serendipity['uriArguments'] = array(PATH_SEARCH, urlencode($serendipity['GET']['searchTerm']));
} else {
$serendipity['uriArguments'][] = PATH_ARCHIVES;
}
$serendipity['GET']['category'] = '2';
include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
You see, I inserted the 'category = 2' line. 2 is the ID of my category (I can see that by hovering over the category sidebar list and look at the URL - first digit before the "-" is always the categoryid.
Try that
Have fun,
Garvin
Working Now
Posted: Thu Feb 10, 2005 4:15 am
by Guest
Wonderful, thank you very much for your help, it's quite appreciated! The modification is working fine, now I can get down to redesigning my journal.
Thanks again, Keep up the good work!
~chris
.7-beta 3
Posted: Sat Feb 19, 2005 2:19 pm
by borzwazie
Can you also do this with the .7 version? I can't find the line you mention anywhere in the index.php at all.
thanks!
Re: .7-beta 3
Posted: Sat Feb 19, 2005 4:00 pm
by borzwazie
borzwazie wrote:Can you also do this with the .7 version? I can't find the line you mention anywhere in the index.php at all.
thanks!
I did this in index.php:
Code: Select all
if (count($serendipity['GET']) == 2) {
if (isset($matches) && is_array($matches) && isset($matches[1])) {
$serendipity['GET']['category'] = $matches[1];
}
ob_start();
$serendipity['GET']['category'] = '6';
include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
which sortof works but now I can only view category 6. so close...[/code]
got it!
Posted: Sat Feb 19, 2005 4:31 pm
by borzwazie
I did this:
Code: Select all
if (count($serendipity['GET']) == 2) {
if (isset($matches) && is_array($matches) && isset($matches[1])) {
$serendipity['GET']['category'] = $matches[1];
} else {
$serendipity['GET']['category'] = '6';
}
ob_start();
This seems to work!