Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2021-07-07 15:54:33

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

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

Another solution is to just add Other in the location custom field and create an additional custom field for the actual place name of an article with an Other location…


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#38 2021-07-10 06:55:28

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

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

I have a question about Oleg’s first suggestion:

etc wrote #330787:

Constructing the list is easy:

<txp:article_custom location fields="location" limit="999" wraptag="ul" break>...

This code outputs all the articles. Because the same city appears in the custom field of several articles, I end up with a list of multiple articles for each city.

I need a custom field list where each city appears only once.

I have tried different approaches, but I can’t quite figure it out…

For example, I tried this:

<txp:article_custom location field="location" limit="999" sort="custom_5 asc" wraptag="ul" break>
<txp:if_different>
    <a href="<txp:site_url />location/<txp:custom_field name="location" />"><txp:custom_field name="location" /></a>
</txp:if_different>
</txp:article_custom>

But then I get empty lines between each city name…

How can I make a list with each city appearing only once?

UPDATE: SOLVED

I made a mistake and typed field instead of fields

This worked:

<txp:article_custom location fields="location" limit="999" sort="custom_5 asc" break="br">
    <a href="<txp:site_url />photos/?location =<txp:custom_field name="location" />"><txp:custom_field name="location" /></a>
</txp:article_custom>

I guess the s in fields makes all the difference?

Last edited by Kjeld (2021-07-10 10:21:21)


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#39 2021-07-10 09:57:39

etc
Developer
Registered: 2010-11-11
Posts: 4,517
Website GitHub

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

Kjeld wrote #330955:

This worked:

<txp:article_custom location fields="location" limit="999" sort="custom_5 asc" break="br">...

I guess the s in fields makes all the difference?

Ahem, what is the difference?

Offline

#40 2021-07-10 10:18:01

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

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

etc wrote #330957:

Ahem, what is the difference?

You used fields, I didn’t. I actually thought you mistyped, so typed field (see my example) … 😅

QUESTION

<txp:article_custom features location and fields="location".

I am probably obtuse, but I can’t seem to find any explanations in the Tag reference index for these two attributes.

Can you explain what they do, how they work, and the difference between fields and field.

Last edited by Kjeld (2021-07-10 10:19:56)


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#41 2021-07-10 10:38:26

etc
Developer
Registered: 2010-11-11
Posts: 4,517
Website GitHub

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

Kjeld wrote #330959:

I am probably obtuse, but I can’t seem to find any explanations in the Tag reference index for these two attributes.

I would certainly bet on the lack of docs :-)

Can you explain what they do, how they work, and the difference between fields and field.

The valueless location filters out the eventual articles with empty location cf, so you don’t get an empty entry in your menu. And fields="location" means ‘extract only different locations’, so

  1. there is no duplicates in your menu;
  2. other article fields are not retrieved from db at all, thus saving memory.

Please feel free to ask questions and, even better, complete the docs.

Offline

#42 2021-07-10 11:05:30

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

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

etc wrote #330960:

I would certainly bet on the lack of docs :-)

The valueless location filters out the eventual articles with empty location cf, so you don’t get an empty entry in your menu. And fields="location" means ‘extract only different locations’, so

  1. there is no duplicates in your menu;
  2. other article fields are not retrieved from db at all, thus saving memory.

Please feel free to ask questions and, even better, complete the docs.

Thank you.

I wasn’t aware that people who are not in the core team can complete the docs… I am not sure if I know Textpattern well enough, but I will keep my eyes open. Do I have to register somewhere if I find something missing?


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#43 2021-07-10 11:22:15

etc
Developer
Registered: 2010-11-11
Posts: 4,517
Website GitHub

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

Kjeld wrote #330961:

Do I have to register somewhere if I find something missing?

Thanks! I think you just need a Github account to submit pull requests to docs repo.

Offline

#44 2021-07-10 12:52:57

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

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

etc wrote #330962:

Thanks! I think you just need a Github account to submit pull requests to docs repo.

Thanks, Oleg.

Github still mystifies and intimidates me… Over the next few weeks, I shall try my best to understand how it all works.


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#45 2021-07-11 08:16:02

etc
Developer
Registered: 2010-11-11
Posts: 4,517
Website GitHub

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

You need very little to submit a request on Github site, especially to complete an existing file.

Offline

#46 2021-07-12 01:38:34

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

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

etc wrote #330977:

You need very little to submit a request on Github site, especially to complete an existing file.

Everything is simple and easy once you know how it works 😉


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

Board footer

Powered by FluxBB