Categories

Having trouble installing serendipity?
Post Reply
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Categories

Post 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?
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Categories

Post 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
# 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/
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Post 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. 8)
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Post 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? :o
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Post by Xanthouos »

Ahh, ok, let me try that. Thanks for the tip. :wink:
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Post 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?
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Post 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...
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
Post Reply