making plugin-related post stick in 3rd position

Creating and modifying plugins.
Post Reply
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

making plugin-related post stick in 3rd position

Post by peggylon »

Hello once more,

I'm running a simple question and answer plugin on my site. The first question went online in march. See http://www.multikulinarisch.es/1044-ges ... e-mrz.html

As long as there is no newer question (sitting in position 1, 2 or 3), I'd like it to stick the last question post (or an additional piece called current question linking to entry 1044) in position 3 of the entries list http://www.multikulinarisch.es.

I tried to use my plugin's entries_header hook in order to somehow exchange positions within the entries array before it gets displayed. So far I managed to retrieve the current position of the latest question post, its timestamp and entryId. Unfortunately there seems to be no $entries I could manipulate and $eventData array is way to complex at this point. Therefore I have no idea whether or how this could be achieved.

If at all possible, the swapping would have to take place before entries.tpl displays the foreach part or even better, before $entries gets assigned to $serendipity['smarty']. Another possible solution might be using javascript.

I'd like to hear your ideas and thoughts on this.

peggylon
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: making plugin-related post stick in 3rd position

Post by garvinhicking »

Hi!

If you really want to switch positions you should probably best do it within the "entry_display" event hook. That one is called in the include/functions_entries.inc.php file in the serendipity_printEntries() function. There you should be able to simply manipulate the $eventData output to switch places...

(You might want to check the pagination URL variables to make sure you only do that on the first page of the blog listing)

(Actually, the more I think about it, doing it via jquery DOM manipulation would be a bit easier, because there pagination might not be as complicated to handle ;))

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/
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

Re: making plugin-related post stick in 3rd position

Post by peggylon »

Thangs Garvin!
I thought about using he entry_display hook, but reconed it might not be suitable since it is employed every time an entry is displayed. I might go with the jQuery DOM manipualtion instead. Its probably saver than mixing up entries.
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
Post Reply