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