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
|
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
|