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.

eZ debug

Timing: Jan 18 2025 11:37:20
Script start
Timing: Jan 18 2025 11:37:20
Module start 'layout'
Timing: Jan 18 2025 11:37:20
Module start 'content'
Timing: Jan 18 2025 11:37:20
Module end 'content'
Timing: Jan 18 2025 11:37:20
Script end

Main resources:

Total runtime0.0256 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0121 588.9219152.6094
Module start 'layout' 0.01210.0041 741.531339.4063
Module start 'content' 0.01620.0068 780.937589.4063
Module end 'content' 0.02300.0026 870.343834.3047
Script end 0.0255  904.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003413.4313140.0002
Check MTime0.00176.7101140.0001
Mysql Total
Database connection0.003112.170210.0031
Mysqli_queries0.004216.500330.0014
Looping result0.00000.074410.0000
Template Total0.00197.410.0019
Template load0.00114.271610.0011
Template processing0.00083.151810.0008
Override
Cache load0.00083.175110.0008
General
dbfile0.00031.322580.0000
String conversion0.00000.046540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs