Forums / Developer / numeric attribute_filter on "Text Line" attribute

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

eZ debug

Timing: Jan 18 2025 14:58:10
Script start
Timing: Jan 18 2025 14:58:10
Module start 'content'
Timing: Jan 18 2025 14:58:11
Module end 'content'
Timing: Jan 18 2025 14:58:11
Script end

Main resources:

Total runtime1.4554 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.8438180.8125
Module start 'content' 0.00551.2616 768.6563624.5313
Module end 'content' 1.26700.1882 1,393.1875341.0547
Script end 1.4552  1,734.2422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.2722210.0002
Check MTime0.00150.1035210.0001
Mysql Total
Database connection0.00060.044210.0006
Mysqli_queries1.370694.17802050.0067
Looping result0.00240.16492030.0000
Template Total1.422397.720.7111
Template load0.00250.172720.0013
Template processing1.419897.554820.7099
Template load and register function0.00010.005310.0001
states
state_id_array0.00140.093410.0014
state_identifier_array0.00380.260820.0019
Override
Cache load0.00210.1472380.0001
Sytem overhead
Fetch class attribute can translate value0.00120.080940.0003
Fetch class attribute name0.00090.062280.0001
XML
Image XML parsing0.00120.081740.0003
class_abstraction
Instantiating content class attribute0.00000.0013110.0000
General
dbfile0.00540.3711340.0002
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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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