Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
[SOLVED] linklists
Is there a way to add an and
just before the final entry in linklists?
ie.
<txp:linklist break=", " wraptag="p" category="thanks"><a rel="external" href="<txp:link_url />"><txp:link_name /></a></txp:linklist>
I am trying to make the above to parse like
Bloke, Oleg, Phil, ruud, and wet
and not
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: [SOLVED] linklists
Try using txp:if_last_link and break=""
:
<txp:linklist break="" wraptag="p" category="thanks"><a rel="external" href="<txp:link_url />"><txp:link_name /></a><txp:if_last_link> and <txp:else/>, </txp:if_last_link></txp:linklist>
TXP Builders – finely-crafted code, design and txp
Offline
Re: [SOLVED] linklists
jakob wrote #314348:
Try using txp:if_last_link and
break=""
:
<txp:linklist break="" wraptag="p" category="thanks"><a rel="external" href="<txp:link_url />"><txp:link_name /></a><txp:if_last_link> and <txp:else/>, </txp:if_last_link></txp:linklist>
Hi Julian
This returns:
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: [SOLVED] linklists
but this one works… and includes the Oxford comma:)
<txp:linklist break="" wraptag="p" break", " category="thanks">
<txp:if_last_link>and </txp:if_last_link><a rel="external" href="<txp:link_url />"><txp:link_name /></a>
</txp:linklist>
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: [SOLVED] linklists
You can do it with CSS:
a+a::before { content: ', ' }
a+a:last-child::before { content: ' and ' }
Offline
Re: [SOLVED] linklists
Of course you’re right.
Or this if you don’t want the oxford comma:
<txp:linklist break="" wraptag="p" category="thanks"><txp:if_last_link> and </txp:if_last_link><a rel="external" href="<txp:link_url />"><txp:link_name /></a><txp:if_last_link><txp:else/>, </txp:if_last_link></txp:linklist>
Maybe <txp:if_last_link not>, </txp:if_last_link>
also works for the second instance of the tag.
TXP Builders – finely-crafted code, design and txp
Offline
Re: [SOLVED] linklists
jakob wrote #314354:
Of course you’re right.
Or this if you don’t want the oxford comma…
Hi Julian, Thanks!!! but the Oxford comma is good. The code might be of use to others though.
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: [SOLVED] linklists
Just make sure that the link list contains more than one link, otherwise you’ll get and wet
.
Offline
Re: [SOLVED] linklists
etc wrote #314359:
Just make sure that the link list contains more than one link, otherwise you’ll get
and wet
.
Hi Oleg,
Indeed. I use it under the vimeo GDPR warning here and in many other pages. That is, I only use it when there is more than one video in the list. The snippet I use is here.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Pages: 1