Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-06-29 12:24:36

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

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

#2 2021-06-29 13:21:38

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

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

#3 2021-06-29 15:04:08

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

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

#4 2021-06-29 16:02:07

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

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

#5 2021-06-29 16:37:17

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

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

#6 2021-06-29 16:49:36

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

Re: How can I create article lists from custom fields?

Kjeld wrote #330797:

Mmm, for some reason it just shows all articles when I do this…

It’s a 4.8+ thing…

Offline

#7 2021-06-29 17:01:48

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

Re: How can I create article lists from custom fields?

etc wrote #330798:

It’s a 4.8+ thing…

I am testing this on 4.8.7…


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

#8 2021-06-29 17:08:52

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

Re: How can I create article lists from custom fields?

Kjeld wrote #330799:

I am testing this on 4.8.7…

Than something interferes :-) I’ve set it up on demo site. Try to replace custom1=txp with custom1=wp. Removing custom1 from URL displays all articles.

Are you sure to edit <txp:article /> in the right page/place?

Offline

#9 2021-06-29 17:25:04

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

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 with custom1=wp. Removing custom1 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

#10 2021-06-29 19:14:04

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

Re: How can I create article lists from custom fields?

Kjeld wrote #330801:

Could these two issues have the same cause?

That’s impossible to say without a closer look.

Offline

#11 2021-06-30 00:45:23

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

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

#12 2021-06-30 08:29:34

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

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

Online

Board footer

Powered by FluxBB