Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Showing articles on home page based on category
Hey guys, I am trying to show a set of articles on my home page based on the category they’re in, and if there are no articles in the category, then it show text. I am using the rss_unlimited_categories plugin, and the code I am using at the moment is this:
<txp:rss_if_article_unlimited_category name="coming-soon">
<txp:output_form form="coming-soon" limit="4" />
<txp:else />
Nothing Here
</txp:rss_if_article_unlimited_category>
The contents of the “coming-soon” form is:
<img src="<txp:custom_field name="ComingSoon125x125" />" alt="" width="125" height="125">
It only seems to output the “Nothing Here” text, and nothing else, regardless if an article is assigned to the “coming-soon” category.
Does any one have any ideas why this may not be working, or any alternative? Thanks!
{Formatted code for better readability. – Uli}
Last edited by uli (2014-10-03 19:04:59)
Offline
Re: Showing articles on home page based on category
I never used the unlimited categories plugin but you could try something like
<txp:variable name=hasarticles value='<txp:rss_unlimited_category_count name="coming-soon" />' />
<txp:if_variable name="hasarticles" value="">Nothing Here<txp:else />
<txp:rss_unlimited_categories_article_list limit="4" />
</txp:if_variable>
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: Showing articles on home page based on category
Does single quotes not solve the problem? Like src='<txp:custom_field name="ComingSoon125x125" />'
.
Offline
Re: Showing articles on home page based on category
Still no luck. I even tried using the Textpattern keywords tag, but that seems to only show the “nothing here”, despite there being two articles with that tag, the code I used there was:
<txp:if_keywords keywords="comingsoon"><txp:output_form form="coming-soon" limit="4" /><txp:else />Nothing Here</txp:keywords>
@Vienuolis: The images load fine if I don’t try to use the if/else. Problem is, there may not always be articles that are upcoming, so I wanted a way to show this
Last edited by SPKuja (2014-10-03 18:29:32)
Offline
Re: Showing articles on home page based on category
Why txp:output_form
, what does it contain? Sorry, I am not familiar with txp:rss_unlimited_categories
too, perhaps Plugin forum might help better.
Offline
#6 2014-10-06 00:34:30
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: Showing articles on home page based on category
Hi SPKuja
You didn’t answer to colaks proposal. It seems to me it should work. Maybe you need a form attribute:
<txp:rss_unlimited_categories_article_list limit="4" form="coming-soon" />
(BTW: The output_form tag has no limit attribute.)
So in your coming-soon form you can put:
<txp:if_custom_field name="ComingSoon125x125">
<txp:image id='<txp:custom_field name="ComingSoon125x125" />' />
</txp:if_custom_field>
In the article custom fields “ComingSoon125x125” you put in each one the image number.
Offline