Templates, fetch and sorting

Author Message

Bruce Morrison

Monday 13 January 2003 11:10:00 pm

Having a need to sort the contents of a fetch I did some digging and have found some information in regards to the "sort_by" parameter of the fetch(content,tree,hash(parameters)) template function (and probally fetch(content,list,hash(parameters)) as well)

sort_by takes (multiple groups - I haven't tried this but the code looks like it will) of 2 parameters

sort field - the field to sort by. Valid options are
'path'
'published'
'modified'
'section'
'depth'
'class_identifier'
'class_name'
'priority'

sort_order
true = ascending
false = desending

So

fetch(content,tree,hash(parent_node_id,29,sort_by,array(published,true))

Will return all nodes under node 29 ordered from the first published to the last published.

If you do not have 2 parameters the sort will default to "path ascending"

I have also patched the system (3 additional lines) to enable to sort by object name. (See http://developer.ez.no/bug/bugview/1773/ )

Hope this helps someone.
Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jan Borsodi

Tuesday 14 January 2003 8:18:36 am

> I have also patched the system (3 additional lines) to
> enable to sort by object name. (See
> http://developer.ez.no/bug/bugview/1773/ )

The name sorting patch has been added to the source with some template additions for selecting it.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Adolfo Barragán

Sunday 19 January 2003 5:14:04 am

> > I have also patched the system (3 additional lines) to
> > enable to sort by object name. (See
> > http://developer.ez.no/bug/bugview/1773/ )
>
> The name sorting patch has been added to the source with
> some template additions for selecting it.

Ok, but if I want sort or filter results by any attribute?

Thanks in advance
Adolfo Barragán

Jan Borsodi

Monday 20 January 2003 3:22:40 am

> > > I have also patched the system (3 additional lines) to
> > > enable to sort by object name. (See
> > > http://developer.ez.no/bug/bugview/1773/ )
> >
> > The name sorting patch has been added to the source with
> > some template additions for selecting it.
>
> Ok, but if I want sort or filter results by any attribute?

This is not implemented yet so you just have to wait ;)

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Paul Borgermans

Monday 20 January 2003 4:43:44 am

> > > > I have also patched the system (3 additional lines)
> to
> > > > enable to sort by object name. (See
> > > > http://developer.ez.no/bug/bugview/1773/ )
> > >
> > > The name sorting patch has been added to the source
> with
> > > some template additions for selecting it.
> >
> > Ok, but if I want sort or filter results by any
> attribute?
>
> This is not implemented yet so you just have to wait ;)

Or can't you do ugly (TM) things in combination with the name patch? Like using the name field for sorting but filling it with the value of any attribute?

Put <attribute-identifier> in the field for the object class name should do the trick? It displays ugly, but may make sense if sorting on any attribute is required.

--------------------natsort anyone?----------------
However, the "order by" clause of Mysql (and others) is rather limited. Perhaps ezp should do a two-staged sorting with php natsort() as an option.

This would get the right sorting order, for example:

fig1.png
fig3.png
fig12.png

instead of

fig1.png
fig12.png
fig3.png

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Jan Borsodi

Wednesday 29 January 2003 3:42:35 am

> However, the "order by" clause of Mysql (and others) is
> rather limited. Perhaps ezp should do a two-staged sorting
> with php natsort() as an option.
>
> This would get the right sorting order, for example:
>
> fig1.png
> fig3.png
> fig12.png
>
> instead of
>
> fig1.png
> fig12.png
> fig3.png

Sorting in php won't work properly with fetch limitations the sorting needs to be done before the limitation.

Secondly natsort is much slower than normal sorting.

A possible solution is to use special sorting tables for attribute and advanced sorting, that way it could be possible to have custom code for sorting specific fields.
We have not decided on anything yet.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Bruce Morrison

Sunday 02 February 2003 11:00:40 pm

> > > > I have also patched the system (3 additional lines)
> to
> > > > enable to sort by object name. (See
> > > > http://developer.ez.no/bug/bugview/1773/ )
> > >
> > > The name sorting patch has been added to the source
> with
> > > some template additions for selecting it.
> >
> > Ok, but if I want sort or filter results by any
> attribute?
>
> This is not implemented yet so you just have to wait ;)

So is this feature going to be in RC2 or the full version?

Having looked at the code I can see how this could be done but do not want to waste time on somthing that is being worked on by the eZ team.

What is happening with the development of eZ3? Last year there seemed to be a regular release schedule (of beta versions) and now nothing since RC1 over a month ago!

I very keen to use this product for a number of projects but deadlines are looming and I am getting quite nervous. I've already invested quite a bit of time into this and would greatly appreciate some news on the release of the next RC or full version.

Thanks
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

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 05:16:41
Script start
Timing: Jan 18 2025 05:16:41
Module start 'layout'
Timing: Jan 18 2025 05:16:41
Module start 'content'
Timing: Jan 18 2025 05:16:42
Module end 'content'
Timing: Jan 18 2025 05:16:42
Script end

Main resources:

Total runtime0.7885 sec
Peak memory usage4,096.0000 KB
Database Queries73

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.1484152.6406
Module start 'layout' 0.00650.0036 741.789139.4766
Module start 'content' 0.01010.7771 781.2656693.7344
Module end 'content' 0.78710.0013 1,475.000024.1484
Script end 0.7884  1,499.1484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3911160.0002
Check MTime0.00140.1722160.0001
Mysql Total
Database connection0.00090.119510.0009
Mysqli_queries0.702689.1069730.0096
Looping result0.00070.0860710.0000
Template Total0.752795.520.3764
Template load0.00240.306820.0012
Template processing0.750395.157820.3752
Template load and register function0.00040.047410.0004
states
state_id_array0.00110.138610.0011
state_identifier_array0.00090.109820.0004
Override
Cache load0.00210.26041240.0000
Sytem overhead
Fetch class attribute can translate value0.00070.091640.0002
Fetch class attribute name0.00100.1309100.0001
XML
Image XML parsing0.00190.240740.0005
class_abstraction
Instantiating content class attribute0.00000.0028130.0000
General
dbfile0.00110.1366300.0000
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
16content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 48
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs