Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-08-06 11:01:21

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Order of txp:category_list not as expected…

After I upgraded to txp 4.7.3, the order of the categories of txp:category_list is no longer as expected…

This is the tag:

<txp:category_list categories="january,february,march,april,may,june,july,august,september,october,november,december" break="br">

I expect the output to be in the order as specified (January, February, March, etc).

BUT, this is the output:

April
August
December
February
January
July
June
March
May
November
October
September

The documentation says: Comma-separated list of categories to include, displayed in the order specified (unless overridden by sort attribute).

Am I missing something?


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#2 2019-08-06 13:51:53

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Order of txp:category_list not as expected…

Did you try, perchance:

<txp:category_list categories="january,february,march,april,may,june,july,august,september,october,november,december" break="br" sort="" />

Offline

#3 2019-08-06 14:23:23

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: Order of txp:category_list not as expected…

Kjeld wrote #318967:

This is the tag:

<txp:category_list categories="january,february,march,april,may,june,july,august,september,october,november,december" break="br">

Is that just the opening tag of a container or the whole tag? If the latter, there lacks the final slash. The tag parser became stricter in interpreting code, so maybe that lacking slash confuses it.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2019-08-08 04:25:02

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Order of txp:category_list not as expected…

uli wrote #318972:

Is that just the opening tag of a container or the whole tag? If the latter, there lacks the final slash. The tag parser became stricter in interpreting code, so maybe that lacking slash confuses it.

It is part of a container, actually.

So, I understand from the two reactions that the tag itself is still fine. I’ll check the complete code still more carefully then to see if there is something that confuses the tag.

Thank you to you both!

Last edited by Kjeld (2019-08-08 04:26:46)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#5 2019-08-08 09:48:56

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 390

Re: Order of txp:category_list not as expected…

Name categories as:
01_january
02_february…
And entitle it as:
January
February…

Alphabetic order relies on category names, not category titles.


<txp:rocks/>

Offline

#6 2019-08-08 09:59:08

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Order of txp:category_list not as expected…

Intere

milosevic wrote #318994:

Name categories as:
01_january
02_february…
And entitle it as:
January
February…

Alphabetic order relies on category names, not category titles.

Very smart suggestion to add numbers! Thank you very much.

The tag is supposed to work with the category names in a specific order. So I most likely have something in my code that interferes. If I can’t figure out what the interference is, I will definitely try your suggestion!


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#7 2019-08-08 10:05:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: Order of txp:category_list not as expected…

Yes, the tag is supposed to work as described in the docs, in the order you specify. Very odd it’s not behaving for you.

Did a quick test on my (admittedly 4.8.0-dev) site and it retains the order I specified if I use the category names the same as you have. Note they’re case sensitive. Presumably your version of MySQL supports FIELD() ordering?

Last edited by Bloke (2019-08-08 10:07:19)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2019-08-08 10:50:49

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Order of txp:category_list not as expected…

Bloke wrote #318996:

Yes, the tag is supposed to work as described in the docs, in the order you specify. Very odd it’s not behaving for you.

Did a quick test on my (admittedly 4.8.0-dev) site and it retains the order I specified if I use the category names the same as you have. Note they’re case sensitive. Presumably your version of MySQL supports FIELD() ordering?

Thank you, Bloke!

Based on the feedback above, I most likely have some interference from other tags within the container. This week-end I should be able to make enough time to sort it all out. If I can’t figure it out, I’ll be back! 😉


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#9 2019-08-10 15:00:41

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Order of txp:category_list not as expected…

Kjeld wrote #318967:

BUT, this is the output:

April
August
December
February
January
July
June
March
May
November
October
September

Seemingly name ASC, that was default before. I don’t remember whether we have changed it in 4.7.3 or only in dev. Strange case, though.

Offline

#10 2019-08-14 12:19:28

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Order of txp:category_list not as expected…

Unfortunately, I was unable to make the order of the categories in txp:category_list work by listing them in a certain order under categories=.…

After lots of testing, I can’t find anything that might be interfering.

So, I followed milosevic’s suggestion and changed the category names to 01-january, 02-february, etc. and sort by name.

This fixes it. But I don’t like that the tag no longer works as described on my site.


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#11 2019-08-14 12:52:58

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Order of txp:category_list not as expected…

You might want to try if the most recent version behaves like it should. If you don’t want to update the entire site to the dev version, find the file /textpattern/publish/taghandlers.php (make a backup to return to if it doesn’t work) and replace the function category_list with the current version from the dev branch here.

I’m not entirely sure whether those changes depend on other aspects. These issues and these two commits seem to be the most recent ones affecting the categories_list tag.


TXP Builders – finely-crafted code, design and txp

Offline

#12 2019-08-14 13:03:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: Order of txp:category_list not as expected…

I’m really interested in figuring out why this doesn’t work for you. Have sent you an email.

As far as I can make out reading the code, in 4.7.3 (maybe even 4.7.2, actually) there is a bug that if you specify a list of categories you must override the sort attribute with sort="", otherwise it will default to name asc. That’s been fixed in current dev by detecting if you’re using the categories attribute and only setting the sort defaults if not.

So I’m intrigued why it didn’t work with Michael’s suggestion at the top of this thread.

Last edited by Bloke (2019-08-14 13:17:03)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB