Page 1 of 1

Sticky Posts

Posted: Sat Jan 31, 2009 7:58 pm
by hubber
Have created a "Sticky" post which I want at the beginning of my front page.

This works, however when I set the sequence of posts to DESC, my sticky post goes to the last page of my blog and doesn't stay where I want it. The only way I can get it to stay on my front page is to sequence as ASC

How can I go ASC and still keep my sticky on top?

Thanks
Hub

Posted: Sun Feb 01, 2009 7:11 pm
by hubber
Anybody?

Re: Sticky Posts

Posted: Sun Feb 01, 2009 8:08 pm
by Don Chambers
How are you changing the sort order to ascending? Knowing that might suggest an answer.

Sticky posts, if I am not mistaken, are treated as the most recent entries... it makes sense that if your sort order says to display oldest entries first, then sticky entries would come last since they are deemed most recent.

Re: Sticky Posts

Posted: Sun Feb 01, 2009 9:46 pm
by hubber
I change sequence using Properties/Templates of categories plugin

I would like the entries to be newest first, with my "sticky" always on top.

When I set it to DESC which is newest first, my sticky, because it is actually the oldest entry goes to the bottom. I thought, being a sticky would override that.

Hub

Re: Sticky Posts

Posted: Mon Feb 02, 2009 10:16 am
by garvinhicking
Hi!

Hm, you might need to change the sort order a bit more specifically, try:

"ep_sticky.value, timestamp ASC"

I think this should order by sticky-value first, and then by timestamp.

HTH,
Garvin

Re: Sticky Posts

Posted: Mon Feb 02, 2009 1:34 pm
by hubber
Garvin,

This keeps the sticky on top, but whether you use ASC or DESC, it doesn't matter, all postings start with the oldest

Re: Sticky Posts

Posted: Mon Feb 02, 2009 2:29 pm
by garvinhicking
Hi!

Hm...that strange. Assuming that ep_sticky.value should always either contain "true" or "false", and the timestamp should vary, then we should first get all entries that have a "sticky value" of "true", and then all those with "false" (non stickies).

Those non-stickies should then be orderted by their timestamp, because their values for the first criteria are the same.

Could you do me a favor and edit your include/functions_entries.inc.php file and search for this:

Code: Select all

    // DEBUG:
    // die($query);
Remove those "//" before the "die" line so that it reads:

Code: Select all

    // DEBUG:
    die($query);
Then save that file and re-load the URL that would get you the wrong sorting. You should now only see a huge line of SQL-Code. Please paste that here; it might be that the ORDER BY statement is wrongly assembled.

An alternative would be to try "orderkey DESC, timestamp ASC" instead?

HTH,
Garvin

Re: Sticky Posts

Posted: Mon Feb 02, 2009 2:55 pm
by hubber
SELECT ep_sticky.value AS orderkey, e.id, e.title, e.timestamp, e.comments, e.exflag, e.authorid, e.trackbacks, e.isdraft, e.allow_comments, e.last_modified, a.realname AS author, a.username AS loginname, a.email , e.body, e.extended FROM serendipity_entries AS e LEFT JOIN serendipity_authors a ON e.authorid = a.authorid LEFT JOIN serendipity_entrycat ec ON e.id = ec.entryid LEFT JOIN serendipity_category c ON ec.categoryid = c.categoryid LEFT OUTER JOIN serendipity_entryproperties ep_no_frontpage ON (e.id = ep_no_frontpage.entryid AND ep_no_frontpage.property = 'ep_no_frontpage') LEFT OUTER JOIN serendipity_entryproperties ep_access ON (e.id = ep_access.entryid AND ep_access.property = 'ep_access') LEFT JOIN serendipity_entryproperties ep_sticky ON (e.id = ep_sticky.entryid AND ep_sticky.property = 'ep_is_sticky') LEFT JOIN serendipity_authorgroups AS acl_a ON acl_a.authorid = 0 LEFT JOIN serendipity_access AS acl_acc ON ( acl_acc.artifact_mode = 'read' AND acl_acc.artifact_type = 'category' AND acl_acc.artifact_id = c.categoryid ) WHERE isdraft = 'false' AND e.timestamp <= 1233582900 AND (ep_access.property IS NULL OR ep_access.value = 'public') AND (ep_no_frontpage.property IS NULL OR ep_no_frontpage.value != 'true') AND ( c.categoryid IS NULL OR ( acl_acc.groupid = 0) OR ( acl_acc.artifact_id IS NULL ) ) GROUP BY e.id ORDER BY "ep_sticky.value, timestamp DESC" LIMIT 2

Re: Sticky Posts

Posted: Mon Feb 02, 2009 3:00 pm
by hubber
Tried "orderkey DESC, timestamp ASC" but same result, can't seem to get sticky first and posts in order newest first.

Re: Sticky Posts

Posted: Mon Feb 02, 2009 3:08 pm
by kleinerChemiker
schon orderkey DESC, timestamp DESC versucht?

Re: Sticky Posts

Posted: Mon Feb 02, 2009 3:13 pm
by garvinhicking
Hi!

The problem is you entered it with quotes! Remove the "" quotes!

Regards,
Garvin

Re: Sticky Posts

Posted: Mon Feb 02, 2009 3:18 pm
by hubber
Dumb!!

Thanks, works just fine.

Hub

Re: Sticky Posts

Posted: Mon Feb 02, 2009 3:21 pm
by garvinhicking
Hi!

Yay, that's great. I was beginning to doubt the sorting logic and couldn't figure it out. :-)

Regards,
Garvin

Re: Sticky Posts

Posted: Mon Feb 02, 2009 3:29 pm
by kleinerChemiker
oh my god, I didn't see that. but I would think, that mysql throws an error with that sql.