Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#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:
- could i make my code more compact?
- how to display commas in a list same color as anchors? they are black at the moment
Offline
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
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
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 nametiirutaja_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
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