Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I sort the most popular articles using a custom field?
I would like to make a list of the most popular articles on my site, sorted from most to least popular.
• I use dzd_counter_view. Each article has a custom field named countxx. When an article is posted, the number “1” is entered into countxx. When an article is viewed, the value of countxx goes up by 1.
• I have created a separate section top-articles with its own page and form:
article tag on page: <txp:article_custom form="top_articles" limit="50" section="photoblog" sort="custom_7 desc" />
top_articles form: <txp:custom_field name="countxx" /> - <txp:permlink><txp:title /></txp:permlink><br />
This gives the output on this page
MY PROBLEM:
The numbers are sorted according to the first digits instead of the value:
997 – Theatre Products
991 – Makoto
9637 – Hijiri Yutoku
9136 – Emiri
899 – Hanae
8255 – Shunpei Kodera
8235 – Yuka
7984 – Yuma Oyaizu
7893 – Ryoko
7673 – Saya
7529 – Yurie
7316 – Aya
71668 – Hitomi Kasuga
MY QUESTION:
What do I need to do to get the list sorted by value?:
71668 – Hitomi Kasuga
9637 – Hijiri Yutoku
9136 – Emiri
8255 – Shunpei Kodera
8235 – Yuka
7984 – Yuma Oyaizu
7893 – Ryoko
7673 – Saya
7529 – Yurie
7316 – Aya
997 – Theatre Products
991 – Makoto
899 – Hanae
• 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 2011-03-04 11:29:46
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do I sort the most popular articles using a custom field?
sort="custom_7 + 0 desc"
Offline
Re: How do I sort the most popular articles using a custom field?
Els wrote:
sort="custom_7 + 0 desc"
Wow, Els, I didn’t know that one.
That did the trick. It now works.
Thanks a lot!
• 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