Sticky News

Author Message

Softriva .com

Thursday 29 March 2007 5:20:57 am

Dears

My client wants to list the latest 10 news items and want to have the ability to make some news items to be sticky which means regardless of date these news items must be displayed. I have this approach

Add checkbox to news class call it sticky
count the number of sticky news (S)
subtracts L=10-S
Fetch sticky news with attribute filter = sticky
Fetch news with limit=L and attribute filter != sticky

Now I have two output array. How can I combine them then sort them for display.

The above is my approach. Do you guys/gals have better solution.

Thank you

OOZY

Sylvain Bannier

Thursday 29 March 2007 10:57:21 am

Hi,

in my opinion this order would be a little faster :
- Fetch sticky news with attribute filter = sticky (limit = 10)
- count the number of sticky news (S)
- subtracts L=10-S
- Fetch news with limit=L and attribute filter != sticky

don't you think ?

Then you could use an operator to merge and sort these nodes.

http://www.smile.fr

Nabil Alimi

Thursday 29 March 2007 11:39:16 am

Hi,

Even faster.

A single fetch where you use the sticky param to sort your result.
Something like this :

{def $list_news=fetch( content , list , hash( parent_node_id , $some_node_id , sort_by , array( array( sticky , true() ) , array( published , false() ) ) , limit , 10 , class_filter_type , 'include' , class_filter_array , array( 'news' ) ) )}

That way, you have one single fetch to deal with. :)

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.