Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
hi all,
could anyone kindly help me with the following?
I'm trying to create a list of pages, sorted according to the values of two editable regions containing only numbers: "paragraph number" aka para_nr, and an optional "subparagraph number" aka sub_nr.

I'm currently using:
Code: Select all
<cms:pages masterpage='index.php' folder=k_folder_name orderby='para_nr, sub_nr' order='asc, asc'>
<li><cms:show para_nr />.<cms:show sub_nr /> <cms:show the_title /></li>
</cms:pages>


Now if my pages contain the following numbers, the list comes out with the following order: 2, 22, 23.1, 23.2, 24, 3, 4, 54

The subparagraph is sorted in the right way, only containing single digits, but the 3 and 4 from the para_nr field are sorted after 22 instead of before it.
What orderby and order parameters would enable me to sort the numbers in the following ascending order: 2, 3, 4, 22, 23.1, 23.2, 24, 54?

I guess the problem is that the para_nr field which determines the sort order is treated as a string of single number rather than a numerical value. Is there a way to treat it as a whole number?
Never mind, I found this: http://docs.couchcms.com/tags-reference/editable.html

It is necessary to set an explicit numeric type on an editable region only when you wish to use the values contained within it to make comparisions (i.e. age < 40) or to sort some output based on these values. See Pages.

Code: Select all
<cms:editable name='para_nr' required='1' type='text' search_type='integer'/>
<cms:editable name='sub_nr' type='text' search_type='integer'/>
More of,
Code: Select all
search_type='decimal'
fits your data samples.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
trendoman wrote: More of,
Code: Select all
search_type='decimal'
fits your data samples.

Thanks.

Yes, I originally created two separate fields, but this probably has no real purpose so I'll probably make it a single field.
4 posts Page 1 of 1