Forums / Install & configuration / Templates, fetch and sorting

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