Textpattern Forum

You are not logged in. Register | Login | Help

#1 2012-07-02 16:40:25

Destry
Moderator
From: Strasbourg, France
Registered: 2004-08-04
Posts: 2,365
Website

[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

#2 2012-07-02 17:01:12

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 5,016
Website

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.org | neme-imca.org | hblack.net | LABS

Offline

#3 2012-07-02 17:03:32

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

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>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2012-07-02 17:16:49

Destry
Moderator
From: Strasbourg, France
Registered: 2004-08-04
Posts: 2,365
Website

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

#5 2012-07-02 17:24:04

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

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)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2012-07-02 17:37:19

Destry
Moderator
From: Strasbourg, France
Registered: 2004-08-04
Posts: 2,365
Website

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

#7 2012-07-02 17:51:52

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

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?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#8 2012-07-02 17:54:06

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

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).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#9 2012-07-02 18:14:48

Destry
Moderator
From: Strasbourg, France
Registered: 2004-08-04
Posts: 2,365
Website

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

#10 2012-07-02 18:24:31

Destry
Moderator
From: Strasbourg, France
Registered: 2004-08-04
Posts: 2,365
Website

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

Board footer

Powered by FluxBB