Forums / Setup & design / Problem with: sort_by

Problem with: sort_by

Author Message

Siw Helen Thorslund

Wednesday 25 May 2005 9:30:14 am

I have a site where it's a listing of news.

I now use:

sort_by, $node.sort_array,

This works fine, but my customer wants to keep a couple of articles on top for a while.

This we could solve with sorting by priority, and give the two articles a higher value than 0. But the problem is that the rest og the articles with the value 0 are by default sorted the wrong way I want the newest first, following the two top articles.

Any of you know how to sort the articles with the value 0 the other way?
Or do any of you have a better solution?

(The customer wants to be able to do this sorting theirselves in the future too.)

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Luke Barton

Wednesday 25 May 2005 11:43:46 am

Consider this.

You could add an attribute to each article that controls its "override sort key" value.

For instance, all articles would default sort by date (or whatever you're already doing).

Then, if the user wishes to set the override sort value for a few articles, the user can set them in the order they wish:

override_sort_val = 1
override_sort_val = 2

You template logic would then search for override_sort_val first, and sort by the attribute value.

Then, your logic would sort the rest by your default sort key.

The user would be responsible for setting the override_sort_val to zero when that article was no longer controlled by override.

Hope this helps or sparks some more ideas.

-Luke

Marko Žmak

Wednesday 25 May 2005 4:59:30 pm

Or you could (without creating
override_sort_val attribute) fetch first the articles that have priority > 0 and sort them by any criterium you want. And then fetch all the rest and sort THEM also by any criterium you want.

It's easier, and convenient because priority can be updated in the admin interface in the listing.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

eZ debug

Timing: Jan 19 2025 00:57:15
Script start
Timing: Jan 19 2025 00:57:15
Module start 'content'
Timing: Jan 19 2025 00:57:16
Module end 'content'
Timing: Jan 19 2025 00:57:17
Script end

Main resources:

Total runtime1.1085 sec
Peak memory usage4,096.0000 KB
Database Queries196

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0089 590.0625180.8438
Module start 'content' 0.00890.9016 770.9063588.2813
Module end 'content' 0.91050.1979 1,359.1875333.0703
Script end 1.1084  1,692.2578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.3761210.0002
Check MTime0.00150.1367210.0001
Mysql Total
Database connection0.00070.065710.0007
Mysqli_queries1.022892.27391960.0052
Looping result0.00260.23081940.0000
Template Total1.066596.220.5332
Template load0.00200.178520.0010
Template processing1.064596.031620.5322
Template load and register function0.00010.009110.0001
states
state_id_array0.00540.483710.0054
state_identifier_array0.00110.095320.0005
Override
Cache load0.00160.1466290.0001
Sytem overhead
Fetch class attribute can translate value0.00200.177240.0005
Fetch class attribute name0.00100.090950.0002
XML
Image XML parsing0.00140.124640.0003
class_abstraction
Instantiating content class attribute0.00000.000750.0000
General
dbfile0.01060.9548350.0003
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs