Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[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  Carry on reading please. 1.
Sample urls (please check the space over Other Texts)
- The author only submitted one article — returnsread end of post.1
- 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
Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?
colak wrote #325250:
I changed the two instances of
EvalElsein the etc_query plugin toparseas 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
Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?
etc wrote #325254:
Try to revert
etc_queryto the previous state and add empty<txp:else />part to the blocks that wrongly output1.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
Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?
No, put this <txp:else /> inside etc_query block.
Offline
Re: [SOLVED] an odd behaviour on txp 4.8.2. etc_query or txp?
etc wrote #325257:
No, put this
<txp:else />insideetc_queryblock.
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
Offline
