Page 1 of 1
Categories
Posted: Tue Jun 26, 2007 5:05 pm
by Xanthouos
How would I go about making it so that when you click on a category link, it will display ONLY the "sticky" or first post of the sub-categories? Is that a possibility?
Re: Categories
Posted: Wed Jun 27, 2007 10:30 am
by garvinhicking
Hi!
That's not possible without writing a custom plugin. Links to categories always show all postings in a category.
Best regards,
Garvin
Posted: Wed Jun 27, 2007 10:44 am
by Xanthouos
Thank you Garvin.
Anyone out there interested in that approach, and have the know-how to make such a plugin?
For the mean time, I'll try a different approach to the matter.

Posted: Wed Jun 27, 2007 12:10 pm
by garvinhicking
Hi!
I personally see no reason for a "sticky only" categories view, so I can't offer help in the plugin creation
You could create your own subcategory containing those entries instead?
Best regards,
Garvin
Posted: Wed Jun 27, 2007 12:16 pm
by Xanthouos
The reason behind it is as follows:
Click on top Category and see the Intro/header post for all the sub-categories.
Then once you click on sub-category, you see all the posts from that category.
...make any sense?

Posted: Wed Jun 27, 2007 12:27 pm
by garvinhicking
Hi!
Yeah, but why not create a subcategory "Top News"? There you'd see all the top News of other categories. You just need to assign those entries also to the "Top News" category (Additional or instead of making them sticky)
Regards,
Garvin
Posted: Wed Jun 27, 2007 12:55 pm
by Xanthouos
Ahh, ok, let me try that. Thanks for the tip.

Posted: Thu Jun 28, 2007 8:49 pm
by Xanthouos
So your idea Garvin solves the issue. Problem I'm facing now is that the post that has more then one category assigned to it, defaults the default template, and not the assigned template for that category.
Make sense?
Posted: Fri Jun 29, 2007 11:22 am
by garvinhicking
Hi!
Ah, I didn't know you were mixing categories. Well...that's a logical problem. How would you tell the category-template which template to prefer in your case of multiple category associations?
Inside the serendipity_event_categorytemplates.php file you'll see this one here:
Code: Select all
function getID() {
global $serendipity;
if ($serendipity['GET']['category'] && !isset($serendipity['GET']['id'])) {
return (int)$serendipity['GET']['category'];
}
if ($serendipity['GET']['id']) {
$entry = serendipity_fetchEntry('id', $serendipity['GET']['id']);
if (count($entry['categories']) == 1) {
return (int)$entry['categories'][0]['categoryid'];
}
}
return 'default';
}
That code only returns the Category-ID for an entry, if the entry has exactly one category assigned.
You could edit that code to add different IF-Checks, like if you wanted to always give Category 12 precedence, if an entry has multiple categories:
Code: Select all
function getID() {
global $serendipity;
if ($serendipity['GET']['category'] && !isset($serendipity['GET']['id'])) {
return (int)$serendipity['GET']['category'];
}
if ($serendipity['GET']['id']) {
$entry = serendipity_fetchEntry('id', $serendipity['GET']['id']);
if (count($entry['categories']) == 1) {
return (int)$entry['categories'][0]['categoryid'];
} else {
foreach($entry['categories'] AS $idx => $cdata) {
if ($cdata['categoryid'] == 12) {
return 12;
}
}
}
}
return 'default';
}
HTH,
Garvin
Posted: Fri Jun 29, 2007 8:18 pm
by Xanthouos
I understand the concept, just not sure how to implement.
As it stands, there is a category called "Camps", which is the second category I will assign to the posts (as in your example you called "top news"). This category and the rest of the posts should have the same template, which is different from the home/main page.
I tried replacing your "12" for "hands" which is the template I need, but didn't seam to work...
Posted: Sat Jun 30, 2007 1:37 pm
by garvinhicking
Hi!
You'll need to replace "12" with the ID, not the name of a category! The ID of a category is usually contained in the URL to your category, like index.php?categories/12-hands. If you put your mouse over the category editing link of the backend, you should see the ID!
Regards,
Garvin