Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-08-09 06:21:32

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

[SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?

>Edit: I think I solved it but still need confirmation.

On our individual texts, pages I’ve been using the following code which returned articles by the same author(s). The authors here are not meant as the txp tag definition but as text authors who have no access to the back-end of the website. The venue cf includes comma separated link ID(s) of those authors and it returns other articles by that person/people.

I just noticed that if there is just one article attributed to the author(s), the code returns 1. Carry on reading please.

Sample urls (please check the space over Other Texts)

  • The author only submitted one articlereturns 1 read end of post.
  • The author only submitted one article and correctly returns nothing.
  • Post plugin edit: The author submitted four articles but the same one is listed 3 times
  • The author submitted two articles — returns the same article.
<div class="sub">
<txp:etc_query name="find" data='<txp:custom_field name="venue" />' markup="list" break=" OR " >FIND_IN_SET({?}, custom_3)</txp:etc_query>
<txp:if_variable name="find">
<txp:etc_query name="relatedtitles" data='(<txp:variable name="find" />) AND ID != <txp:article_id />' markup="db" populate="article"  wraptag="ul" class="related_articles" label="By the same author" labeltag="h3">
<txp:variable name="relatedtexts" value='<txp:variable name="relatedtexts" />,<txp:article_id />' />
{$<({#row}|21).?(<li><a href="<txp:permlink />"><txp:title /></a></li>)}
</txp:etc_query>
</txp:if_variable>
<txp:variable name="relatedtitles" />
<txp:article_custom sort="rand()" section="texts" exclude='<txp:article_id />,<txp:variable name="relatedtexts" />' limit='<txp:if_variable name="relatedtexts">15<txp:else />20</txp:if_variable>' break="li" wraptag="ul" class="submenu" label="Other Texts" labeltag="h3">
<a href="<txp:permlink />"><txp:title /></a>
</txp:article_custom>
</div>

I changed the two instances of EvalElse in the etc_query plugin to parse as per Oleg’s suggestion here but it now returns the current article as opposed to nothing.

ps. Oleg, if you do read this one, I visited your site to see if there was a newer version of the plugin but it returned 404s. Just a heads-up.

Last edited by colak (2020-08-09 07:30:18)


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 2020-08-09 07:50:33

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

Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?

colak wrote #325250:

I changed the two instances of EvalElse in the etc_query plugin to parse as per Oleg’s suggestion here but it now returns the current article as opposed to nothing.

Try to revert etc_query to the previous state and add empty <txp:else /> part to the blocks that wrongly output 1.

Oleg, if you do read this one, I visited your site to see if there was a newer version of the plugin but it returned 404s. Just a heads-up.

Yep, our server is on summer vacancy.

Offline

#3 2020-08-09 08:13:11

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

Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?

etc wrote #325254:

Try to revert etc_query to the previous state and add empty <txp:else /> part to the blocks that wrongly output 1.

Yep, our server is on summer vacancy.

Thanks, I did but it still returns 1.

<div class="sub">
<txp:etc_query name="find" data='<txp:custom_field name="venue" />' markup="list" break=" OR " >FIND_IN_SET({?}, custom_3)</txp:etc_query>
<txp:if_variable name="find">
<txp:etc_query name="relatedtitles" data='(<txp:variable name="find" />) AND ID != <txp:article_id />' markup="db" populate="article"  wraptag="ul" class="related_articles" label="By the same author" labeltag="h3">
<txp:variable name="relatedtexts" value='<txp:variable name="relatedtexts" />,<txp:article_id />' />
{$<({#row}|21).?(<li><a href="<txp:permlink />"><txp:title /></a></li>)}
</txp:etc_query>
<txp:else />
</txp:if_variable>
<txp:variable name="relatedtitles" />
<txp:article_custom sort="rand()" section="texts" exclude='<txp:article_id />,<txp:variable name="relatedtexts" />' limit='<txp:if_variable name="relatedtexts">15<txp:else />20</txp:if_variable>' break="li" wraptag="ul" class="submenu" label="Other Texts" labeltag="h3">
<a href="<txp:permlink />"><txp:title /></a>
</txp:article_custom>
</div>

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 2020-08-09 08:15:43

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

Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?

No, put this <txp:else /> inside etc_query block.

Offline

#5 2020-08-09 10:17:52

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

Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?

etc wrote #325257:

No, put this <txp:else /> inside etc_query block.

Whoops! Mea culpa

final working code

<div class="sub">
<txp:etc_query name="find" data='<txp:custom_field name="venue" />' markup="list" break=" OR " >FIND_IN_SET({?}, custom_3)</txp:etc_query>
<txp:if_variable name="find">
<txp:etc_query name="relatedtitles" data='(<txp:variable name="find" />) AND ID != <txp:article_id />' markup="db" populate="article"  wraptag="ul" class="related_articles" label="By the same author" labeltag="h3">
<txp:variable name="relatedtexts" value='<txp:variable name="relatedtexts" />,<txp:article_id />' />
{$<({#row}|21).?(<li><a href="<txp:permlink />"><txp:title /></a></li>)}
<txp:else />
</txp:etc_query>
</txp:if_variable>
<txp:variable name="relatedtitles" />
<txp:article_custom sort="rand()" section="texts" exclude='<txp:article_id />,<txp:variable name="relatedtexts" />' limit='<txp:if_variable name="relatedtexts">15<txp:else />20</txp:if_variable>' break="li" wraptag="ul" class="submenu" label="Other Texts" labeltag="h3">
<a href="<txp:permlink />"><txp:title /></a>
</txp:article_custom>
</div>

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

Offline

#6 2020-08-09 11:48:13

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

Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?

colak wrote #325262:

Whoops! Mea culpa

No worries, we are two :-) For the record (and awaiting 4.8.3), to fix this 1-issue in any plugin, add empty <txp:else /> part to its content if <txp:else /> is not already there.

Offline

Board footer

Powered by FluxBB