Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[Solved ]"Sticky" excerpt + article list at the same time
This is what I’ve got going at the moment on a section page template. The functional concept is thus: If visitor lands on landing section (domain.tld/section
), they get the sticky article’s excerpt followed by a list of articles (titles only) for that section, otherwise they get a full single article (domain.tld/section/article-title
).
<txp:if_individual_article>
<p class="excerpt"><txp:excerpt /></p>
<txp:body />
<txp:else />
<txp:if_article_id id="136">
<p class="excerpt"><txp:excerpt /></p>
</txp:if_article_id>
<txp:if_first_article><ul></txp:if_first_article>
<li><a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:if_individual_article>
It works if article id=136
is not set as “sticky”, but then the same article also appears in the list underneath. I don’t want it in both places. If I change article 136 to ‘sticky’, the excerpt doesn’t show up.
You see what I mean?
Ultimately, I want the landing page excerpt separate from the list underneath. Whether or not it’s a sticky article, I don’t really care, but I thought that was how it was supposed to work. Maybe I don’t play with Txp enough anymore.
Any clue/solution on that would be greatly appreciated.
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Hi Destry
Maybe if you replace
<txp:if_article_id id="136">
<p class="excerpt"><txp:excerpt /></p>
</txp:if_article_id>
with
<txp:if_article_id id="136">
<txp:article_custom status="sticky" id="136"><p class="excerpt"><txp:excerpt /></p></txp:article_custom>
</txp:if_article_id>
you might get what you want
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 ]"Sticky" excerpt + article list at the same time
Hi Destry.
I assume there is somewhere a <txp:article>
tag wrapping the conditionals.
If so, I think problem is that that tag will fetch/output live or sticky articles, but not both.
I’d go with something like this:
<txp:if_individual_article>
<txp:article>
<p class="excerpt"><txp:excerpt /></p>
<txp:body />
</txp:article>
<txp:else />
<txp:article_custom id="136">
<p class="excerpt"><txp:excerpt /></p>
</txp:article_custom>
<txp:article>
<txp:if_first_article><ul></txp:if_first_article>
<li><a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:article>
</txp:if_individual_article>
Or something like this (to avoid hardcoding the id
)
<txp:if_individual_article>
<txp:article>
<p class="excerpt"><txp:excerpt /></p>
<txp:body />
</txp:article>
<txp:else />
<txp:article_custom status="sticky" section='<txp:section />' limit="1">
<p class="excerpt"><txp:excerpt /></p>
</txp:article_custom>
<txp:article>
<txp:if_first_article><ul></txp:if_first_article>
<li><a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:article>
</txp:if_individual_article>
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Hi guys, thanks.
@colak: I hadn’t thought to try that, but it didn’t work.
@maniqui: That works, except I’m getting multiple outputs; excerpt + article list four times in a row (the number of current ‘live’ articles in that section).
N.B.: That not hard-coding the ID number was going to be my next step, in fact. :)
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Did you remove the wrapping <txp:article />
around your conditionals? (I forgot to state that)
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
If what you mean is this…
<txp:if_individual_article>
<p class="excerpt"><txp:excerpt /></p>
<txp:body />
<txp:else />
<txp:article_custom status="sticky" section='<txp:section />' limit="1">
<p class="excerpt"><txp:excerpt /></p>
</txp:article_custom>
<txp:if_first_article><ul></txp:if_first_article>
<li><a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:if_individual_article>
That’s not working either; giving me a very strange output… inserting the excerpt after each of the article titles, so the article list is correct, perhaps, but the excerpt appears five times (at the top and after each live article title).
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Nope.
I assumed that you had something like this at the beginning.
<txp:article>
<txp:if_individual_article>
<p class="excerpt"><txp:excerpt /></p>
<txp:body />
<txp:else />
<txp:if_article_id id="136">
<p class="excerpt"><txp:excerpt /></p>
</txp:if_article_id>
<txp:if_first_article><ul></txp:if_first_article>
<li><a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:if_individual_article>
</txp:article>
But, now, given your feedback, I understand that you haven’t been using txp:article
as a wrapping tag, but just using the form
attribute. Did I guess it right this time?
So, somewhere in your (page) template you have an txp:article
tag using the form
attribute to call your original form.
<txp:article form="crazy_excerpt_sticky_live_article_list_a_la_Destry_style" />
Now, I want you to replace that with
<txp:output_form form="maniqui_form" />
And in maniqui_form
, just put this:
<txp:if_individual_article>
<txp:article>
<p class="excerpt"><txp:excerpt /></p>
<txp:body />
</txp:article>
<txp:else />
<txp:article_custom status="sticky" section='<txp:section />' limit="1">
<p class="excerpt"><txp:excerpt /></p>
</txp:article_custom>
<txp:article>
<txp:if_first_article><ul></txp:if_first_article>
<li><a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:article>
</txp:if_individual_article>
Does it make more sense now?
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Alternatively, if you are not planning on reusing the form, just paste the contents of maniqui_form
directly in your page template, where you would have put the txp:output_form
tag (which, previously, in your original code, it was a txp:article
tag).
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Sorry, I should have been more clear about what was in the page template and what was in the form. Yes, originally, the page template is where there was an article form=""
tag calling the form. The form contained everything I indicated in the first post.
Anyway, changing the page to an output_form
calling the form, and using the “maniqui” content indicated above, still doesn’t work. I get the excerpt only once now (at least there’s that), but I’m getting the ‘live’ articles as full articles instead of just a list of titles.
There seems to be a problem with this part now, but I don’t know why…
<txp:article>
<txp:if_first_article><ul></txp:if_first_article>
<li><a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:article>
If I remove the surrounding article
container on just this part, it doesn’t change anything.
Yes, I’ll reuse this form, if I can actually get it to work.
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Hang on. Suddenly all my articles are not going to the appropriate sections. Everything is weird now. I’ll look at this tonight and report back tomorrow.
Offline
#11 2012-07-02 20:16:16
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: [Solved ]"Sticky" excerpt + article list at the same time
Looking at the tag trace might save you some time :)
Offline
Re: [Solved ]"Sticky" excerpt + article list at the same time
Thanks Els. Good idea.
I have one tag error repeating three times; exactly the same each time. Here’s data for one of them…
Tag error: <txp:else /> -> Textpattern Warning: tag does not exist on line 1202
textpattern/publish.php:1202 trigger_error()
textpattern/publish.php:1100 processTags()
textpattern/publish/taghandlers.php:3694 parse()
textpattern/publish.php:1188 if_section()
textpattern/publish.php:1113 processTags()
textpattern/lib/txplib_misc.php:1706 parse()
textpattern/publish/taghandlers.php:314 parse_form()
textpattern/publish.php:1188 output_form()
textpattern/publish.php:1100 processTags()
textpattern/lib/txplib_misc.php:1706 parse()
I’m not sure what to make of it because the else
tag is there in the form.
Offline