Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How can I create article lists from custom fields?
The answer to my problem is probably very simple, but I can’t figure it out…
I use the long orphaned chh_keywords to create article lists from entries in custom fields.
For example, I have one custom field called location. In this custom field I enter the name of a city.
On the right column of my site there is a list of all the cities entered in the location custom field (created with chh_keywords_list_all
which lists all the keywords from a particular field). The city names are links.
When you click on one of the cities, you get a list of all the articles (created by using chh_keywords_articles
) for that city (Tokyo, for example). The link is clean and simple: https://www.oldphotosjapan.com/location/Tokyo
.
Basically, each custom field is used as an extra category.
How can I do this without using chh_keywords?
Last edited by Kjeld (2021-06-29 12:24:53)
• 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
Re: How can I create article lists from custom fields?
Constructing the list is easy:
<txp:article_custom location fields="location" limit="999" wraptag="ul" break>
<txp:site_url />location/<txp:custom_field name="location" />
</txp:article_custom>
Outputting the articles is more cumbersome, you’ll need a plugin or .htaccess
rewrite, to transform
https://www.oldphotosjapan.com/location/Tokyo
into, say,
https://www.oldphotosjapan.com/?location=Tokyo
After that, <txp:article match="location" />
should do the trick, maybe with few tweaks.
Offline
Re: How can I create article lists from custom fields?
etc wrote #330787:
Constructing the list is easy:
<txp:article_custom location fields="location" limit="999" wraptag="ul" break>...
Outputting the articles is more cumbersome, you’ll need a plugin or
.htaccess
rewrite, to transform
https://www.oldphotosjapan.com/location/Tokyo...
into, say,
https://www.oldphotosjapan.com/?location=Tokyo...
After that,
<txp:article match="location" />
should do the trick, maybe with few tweaks.
Thank you!
If I give up on maintaining the form of the url, is there a more straightforward way to list articles according to custom fields?
• 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
Re: How can I create article lists from custom fields?
Kjeld wrote #330789:
If I give up on maintaining the form of the url, is there a more straightforward way to list articles according to custom fields?
Certainly, just replace <txp:article />
with <txp:article match="location" />
and visit www.oldphotosjapan.com/?location=Tokyo. If needed, you can filter by multiple cf too:
<txp:article match="location, period" />
Offline
Re: How can I create article lists from custom fields?
etc wrote #330795:
Certainly, just replace
<txp:article />
with<txp:article match="location" />
and visit www.oldphotosjapan.com/?location=Tokyo. If needed, you can filter by multiple cf too:
<txp:article match="location, period" />...
Mmm, for some reason it just shows all articles when I do this…
I must be doing something wrong, or some other coding interferes?
Incidentally, I get no errors in Debugging mode.
• 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
Offline
Re: How can I create article lists from custom fields?
• 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
Re: How can I create article lists from custom fields?
Offline
Re: How can I create article lists from custom fields?
etc wrote #330800:
Than something interferes :-) I’ve set it up on demo site. Try to replace
custom1=txp
withcustom1=wp
. Removingcustom1
from URL displays all articles.Are you sure to edit
<txp:article />
in the right page/place?
Mmmm, my site appears to have an issue.
I also have this issue on the same site.
Could these two issues have the same cause?
• 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
Offline
Re: How can I create article lists from custom fields?
etc wrote #330802:
That’s impossible to say without a closer look.
Thank you. Any idea where I should start looking for possible causes?
I have already done the regular things like emptying cashes, refreshing, reinstalling plugins, turning off other plugins, checking Debugging mode. The .htaccess files also seem fine to me, but I might be missing something.
If I manage to make some extra time today, I will try to create another installation on txp on a similar subdomain as the one with the issues is installed on. Just to see if I run into the same issues.
• 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
Re: How can I create article lists from custom fields?
No ideas offhand if you’ve tried the usual stuff, sorry. Feel free to send me a login if possible to the test subdomain, and I’ll see if I can help figure it out.
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