Sticky Posts

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
hubber
Regular
Posts: 30
Joined: Fri Jun 20, 2008 7:01 pm

Sticky Posts

Post 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
hubber
Regular
Posts: 30
Joined: Fri Jun 20, 2008 7:01 pm

Post by hubber »

Anybody?
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Sticky Posts

Post 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.
=Don=
hubber
Regular
Posts: 30
Joined: Fri Jun 20, 2008 7:01 pm

Re: Sticky Posts

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Sticky Posts

Post 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
# 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/
hubber
Regular
Posts: 30
Joined: Fri Jun 20, 2008 7:01 pm

Re: Sticky Posts

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Sticky Posts

Post 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
# 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/
hubber
Regular
Posts: 30
Joined: Fri Jun 20, 2008 7:01 pm

Re: Sticky Posts

Post 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
hubber
Regular
Posts: 30
Joined: Fri Jun 20, 2008 7:01 pm

Re: Sticky Posts

Post by hubber »

Tried "orderkey DESC, timestamp ASC" but same result, can't seem to get sticky first and posts in order newest first.
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Re: Sticky Posts

Post by kleinerChemiker »

schon orderkey DESC, timestamp DESC versucht?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Sticky Posts

Post by garvinhicking »

Hi!

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

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/
hubber
Regular
Posts: 30
Joined: Fri Jun 20, 2008 7:01 pm

Re: Sticky Posts

Post by hubber »

Dumb!!

Thanks, works just fine.

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

Re: Sticky Posts

Post by garvinhicking »

Hi!

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

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/
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Re: Sticky Posts

Post by kleinerChemiker »

oh my god, I didn't see that. but I would think, that mysql throws an error with that sql.
Post Reply