Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-08-16 06:10:03

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

Linklist bug?

Bug?

With an empty break attribute, it works fine

<txp:linklist category="textpattern" wraptag="ul" break="" sort="id desc" labeltag="h4" label="txp links" limit="5" form="">
<txp:variable name="has_description"><txp:link_description /></txp:variable>
<txp:if_variable name="has_description" value="">
<txp:else />
<li><txp:link_description />: <a href="<txp:link_url />"><txp:link_name /></a></li>
</txp:if_variable>
</txp:linklist>

With a defined break attribute, we get some additional empty lis

<txp:linklist category="textpattern" wraptag="ul" break="li" sort="id desc" labeltag="h4" label="txp links" limit="5" form="">
<txp:variable name="has_description"><txp:link_description /></txp:variable>
<txp:if_variable name="has_description" value="">
<txp:else />
<txp:link_description />: <a href="<txp:link_url />"><txp:link_name /></a>
</txp:if_variable>
</txp:linklist>

Tested on the latest vanilla release, in an article.


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

Offline

#2 2021-08-16 07:58:14

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

Re: Linklist bug?

colak wrote #331352:

Bug?

Feature :-) Historically, empty items are not removed from the lists (linklist or other). Additionally, in your construction they are never empty, containing few linebreaks even when has_description variable is empty. To fix, try adding trim attribute:

<txp:linklist trim ... />

Offline

#3 2021-08-16 08:30:51

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

Re: Linklist bug?

etc wrote #331353:

Feature :-) Historically, empty items are not removed from the lists (linklist or other). Additionally, in your construction they are never empty, containing few linebreaks even when has_description variable is empty. To fix, try adding trim attribute:

<txp:linklist trim ... />...

That does indeed fix the issue!


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

Offline

#4 2021-08-16 09:12:13

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

Re: Linklist bug?

colak wrote #331354:

That does indeed fix the issue!

Fine! I would actually vote for removing empty items by default, but it’s not fully bw-compatible, and txp users creativity is often beyond normal.

Offline

#5 2021-08-16 09:33:23

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,279
GitHub

Re: Linklist bug?

etc wrote #331355:

[…] txp users creativity is often beyond normal.

I love this, by the way.

Offline

#6 2021-08-16 09:41:07

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

Re: Linklist bug?

gaekwad wrote #331358:

I love this, by the way.

Me too, though I would go with a boring

<txp:linklist evaluate="link_description" wraptag="ul" break="li" ...>
    <txp:link_description />: <a href="<txp:link_url />"><txp:link_name /></a>
</txp:linklist>

Offline

#7 2021-08-16 13:36:13

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

Re: Linklist bug?

etc wrote #331359:

Me too, though I would go with a boring

<txp:linklist evaluate="link_description" wraptag="ul" break="li" ...>...

the modern way is so much better to my classicist gymnastics!!!


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

Offline

#8 2021-08-16 13:47:05

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

Re: Linklist bug?

colak wrote #331366:

the modern way is so much better to my classicist gymnastics!!!

Old dogs we are :-)

Offline

#9 2021-08-16 16:48:35

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

Re: Linklist bug?

etc wrote #331369:

Old dogs we are :-)

A very old dog, I have become:)

There still an issue which I can not duplicate on the demo site.

This is what I use in an article.

<txp:linklist category="active" evaluate="link_description" sort="id desc" wraptag="ul" break="li" labeltag="h4" label="Latest emails" limit="20" form=""><txp:link_description />: <a href="<txp:link_url />"><txp:link_name /></a></txp:linklist>
<txp:linklist category="expired" evaluate="link_description" sort="id desc" wraptag="ul" break="li" labeltag="h4" label="Past emails" limit="5" form=""><txp:link_description />: <a href="<txp:link_url />"><txp:link_name /></a></txp:linklist>

The output parses everything as expected when there is an entry in the active link category but the label and labeltag are omitted from the expired category when there is no entry in the active category. This is indeed a gremlin for me. (I did check the source too).


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

Offline

#10 2021-08-16 21:24:45

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

Re: Linklist bug?

colak wrote #331375:

The output parses everything as expected when there is an entry in the active link category but the label and labeltag are omitted from the expired category when there is no entry in the active category. This is indeed a gremlin for me. (I did check the source too).

This is by design, labels are created only when the list is not empty. If you want them unconditionally, prepend them manually.

Offline

#11 2021-08-17 00:10:38

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

Re: Linklist bug?

etc wrote #331369:

Old dogs we are :-)

me too. evaluate is one of those “new” attributes (ahem, it has been there for a little bit) that I keep forgetting at first. Bit is is soooo useful.

Last edited by phiw13 (2021-08-17 00:11:01)


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

Offline

#12 2021-08-17 03:34:22

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

Re: Linklist bug?

etc wrote #331383:

This is by design, labels are created only when the list is not empty. If you want them unconditionally, prepend them manually.

Maybe I did not explain it correctly. The expired list is never empty but its label and labeltag are omitted when the active list is empty.


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

Offline

Board footer

Powered by FluxBB