Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: troubles with txp:related_articles
As txp:related_articles makes use of txp:article_custom internally, maybe adding the attribute status="4"
may help. I’m not sure but try that first.
Alternatively, try you could do it in two steps:
<txp:variable name="random_related_articles"><txp:related_articles limit="10" wraptag="" break="," sort="rand()" section='<txp:section />' ><txp:article_id /></txp:related_articles></txp:variable>
<txp:article_custom limit="4" status="live" id='<txp:variable name="random_related_articles" />' wraptag="ul" break="li">
<div class="related-image">
<a href="<txp:permlink />" rel="bookmark" title="<txp:title />"><txp:article_image thumbnail="1" width="230" height="180" /></a>
<div class="related-text">
<a href="<txp:permlink />"><txp:title /></a>
</div>
</div>
<div class="related-small">
<a href="<txp:permlink />" class="related-headline"><txp:title /></a>
</div>
</txp:article_custom>
Maybe something like that? If you have a lot of sticky articles, you might have to adjust the limit
attribute in the first part to ensure you always have enough to get 4 live articles in the second part.
TXP Builders – finely-crafted code, design and txp
Offline
Re: troubles with txp:related_articles
It’s another silly bug of mine, sorry. Awaiting 4.7.2, you can do the following
<txp:related_articles limit="4" wraptag="ul" break="" sort="Status, rand()" section='<txp:section />'>
<txp:if_custom_field name="status" value="4">
<li>
<div class="related-image">
<a href="<txp:permlink />" rel="bookmark" title="<txp:title />"><txp:article_image thumbnail="1" width="230" height="180" /></a>
<div class="related-text">
<a href="<txp:permlink />"><txp:title /></a>
</div>
</div>
<div class="related-small">
<a href="<txp:permlink />" class="related-headline"><txp:title /></a>
</div>
</li>
</txp:if_custom_field>
</txp:related_articles>
Offline
#15 2018-08-02 21:26:49
- singaz
- Member
- Registered: 2017-03-12
- Posts: 150
Re: troubles with txp:related_articles
jakob, thank you!
etc, thank you!
I decided my question.
I like textpattern. I like the community.
I’ve been trying to do this myself for a long time. And I got a quick response from the community.
Thank you.
Sorry my horror English. I’m learning textpattern, I’m learning English
Offline