Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-06-12 12:33:01

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

Restrict to articles with specified value for specified custom field

hi!

created article list with restricted articles (at a bottom) with specified value for specified custom field name:

<txp:article_custom tiirutaja_nr='<txp:if_custom_field name="tiirutaja_nr"><txp:custom_field name="tiirutaja_nr" /></txp:if_custom_field>' limit="1" limit="80" wraptag="" label="Selles numbris veel:" labeltag="h6" sort="Posted desc" break="," trim>
<txp:if_article_id>
    <txp:else />
<txp:permlink><txp:title /></txp:permlink>
</txp:if_article_id>
</txp:article_custom>

works well. but, 2 little questions:

  1. could i make my code more compact?
  2. how to display commas in a list same color as anchors? they are black at the moment

Offline

#2 2024-06-12 20:32:21

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

Re: Restrict to articles with specified value for specified custom field

You can try a little simpler

<txp:article_custom id exclude="id" match="tiirutaja_nr" limit="80" wraptag="" label="Selles numbris veel:" labeltag="h6" sort="Posted desc" break="," trim>
    <txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>

Offline

#3 2024-06-12 23:58:46

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,196
Website

Re: Restrict to articles with specified value for specified custom field

how to display commas in a list same color as anchors? they are black at the moment

You can set the color (same as link color) on the immediate parent element, maybe ?


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#4 2024-06-13 08:17:54

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

Re: Restrict to articles with specified value for specified custom field

etc wrote #337277:

You can try a little simpler

<txp:article_custom id exclude="id" match="tiirutaja_nr" limit="80" wraptag="" label="Selles numbris veel:" labeltag="h6" sort="Posted desc" break="," trim>...

Gorgeous!

Now I need to work on with my styling. not looking good at the moment, especially in my phone screen (big gaps between link and black commas)

Offline

#5 2024-07-11 07:49:22

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

Re: Restrict to articles with specified value for specified custom field

etc wrote #337277:

You can try a little simpler

<txp:article_custom id exclude="id" match="tiirutaja_nr" limit="80" wraptag="" label="Selles numbris veel:" labeltag="h6" sort="Posted desc" break="," trim>...

One little problem came out using this code. If Costom field name tiirutaja_nr empty, it binds together also articles wich custom field name tiirutaja_nr is empty.

Offline

#6 2024-07-11 07:55:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Restrict to articles with specified value for specified custom field

Gallex wrote #337395:

One little problem came out using this code. If Costom field name tiirutaja_nr empty, it binds together also articles wich custom field name tiirutaja_nr is empty.

Would this work for you?

<txp:article_custom id exclude="id" limit="80" wraptag="" label="Selles numbris veel:" labeltag="h6" sort="Posted desc" break="," trim>
<txp:if_custom_field name="tiirutaja_nr">
<txp:title />
</txp:if_custom_field>
</txp:article_custom>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2024-07-11 07:58:24

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

Re: Restrict to articles with specified value for specified custom field

Can you simply avoid that specific case from reaching the tag by wrapping the entire code in an if_custom_field tag? e.g.

<txp:if_custom_field name="tiirutaja_nr" value="" not>
    <!-- tiirutaja_nr custom field is not empty -->
    <txp:article_custom id exclude="id" match="tiirutaja_nr" limit="80" wraptag="" label="Selles numbris veel:" labeltag="h6" sort="Posted desc" break="," trim>
        <txp:permlink><txp:title /></txp:permlink>
    </txp:article_custom>
<txp:else />
    <!-- do something else -->
</txp:if_custom_field>

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB