numeric attribute_filter on "Text Line" attribute

Author Message

Sébastien Morel

Monday 17 September 2007 7:51:41 am

Hi,

I have a simple question :
How make a fetch attribute filter with numeric sort on a "Text Line" attribute ?

I have a class with a text line attribute, the content of this attribute in all object is always numeric but at the origin of the project. This attribute must be a string...

So, today I had to do a attribute_filter greater than a number, but like my attribute is a text line eZ sort in alphanumeric mode...

Thanks for your help.

Séb

--
eZ c'est plus fort que toi !
http://www.ez-france.org
http://blog.plopix.net
@Novactive (http://www.novactive.com)

Olivier Ouin

Monday 17 September 2007 8:33:40 am

And alphanumeric sort result is different of a pure numeric sort with numeric strings ??
Strange ...

You should see how works extended attributes filter, you can do some complex queries with it.

Personnaly, I would build my own custom fetch method in an extension, it's not really difficult.
In it, you could "normally" fetch your nodes, associate it in an array with the line text content, parse the array to convert the line text content to a pure numeric type, then sort it according to numeric values, and finally return the sorted nodes.

Sébastien Morel

Monday 17 September 2007 9:33:07 am

Ok, I would say "alphabetic sort" with "Text Line" attribute .(it's a little vocabularary differences ;))

In fact in my case 205 is lesser than 60 because eZ sort in alphabetic mode because the type of my attribute is "Text line".

Someone else have a idea ?

Thanks

--
eZ c'est plus fort que toi !
http://www.ez-france.org
http://blog.plopix.net
@Novactive (http://www.novactive.com)

André R.

Monday 17 September 2007 11:52:13 pm

You should probably convert it using ezchangeclass, you can write custom converter code for the ezstring to ezint conversion.

It's quite simple, you only need to map data_string to data_int.
PS: ezchangeclass contains a couple of known bugs, so I will upload the new version later today!

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Sébastien Morel

Tuesday 18 September 2007 1:09:18 am

I was expecting such an anwser...

Is there another way ?

Thanks anyway ;)

--
eZ c'est plus fort que toi !
http://www.ez-france.org
http://blog.plopix.net
@Novactive (http://www.novactive.com)

André R.

Tuesday 18 September 2007 2:44:18 am

hmm, not that I can think of right now, but added a string to int/float converter my self.
So you can give it a test straight away:

http://ez.no/community/contribs/applications/object_content_class_change

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

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 18:18:47
Script start
Timing: Jan 18 2025 18:18:47
Module start 'layout'
Timing: Jan 18 2025 18:18:47
Module start 'content'
Timing: Jan 18 2025 18:18:48
Module end 'content'
Timing: Jan 18 2025 18:18:48
Script end

Main resources:

Total runtime0.6028 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 588.0469152.6406
Module start 'layout' 0.00650.0031 740.687539.4766
Module start 'content' 0.00960.5919 780.1641619.4375
Module end 'content' 0.60150.0013 1,399.601616.1250
Script end 0.6028  1,415.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5241160.0002
Check MTime0.00140.2255160.0001
Mysql Total
Database connection0.00090.144310.0009
Mysqli_queries0.538689.3442680.0079
Looping result0.00070.1105660.0000
Template Total0.570994.720.2854
Template load0.00220.364620.0011
Template processing0.568694.328820.2843
Template load and register function0.00010.020910.0001
states
state_id_array0.00100.162910.0010
state_identifier_array0.00120.195920.0006
Override
Cache load0.00190.3124380.0000
Sytem overhead
Fetch class attribute can translate value0.00090.144230.0003
Fetch class attribute name0.00110.174580.0001
XML
Image XML parsing0.00110.186630.0004
class_abstraction
Instantiating content class attribute0.00000.0034110.0000
General
dbfile0.00100.1623230.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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/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: 27
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs