Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2012-07-02 23:12:45

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

Mmmmm… look for some typo or error in code, like an <txp:else /> not nested inside conditional tags, or maybe a malformed tag.
At least, the times that a similar error pop-up on me, it usually was that kind of mistake.

Also, while there, you could simplify this:

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

To this:

<txp:article wraptag="ul" break="li">
  <a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a>
</txp:article>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#14 2012-07-02 23:39:25

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

Well, maybe I need another pair of eyes. This is exactly as it is in the form now, and I still get the errors…

<txp:if_individual_article>

      <txp:article>
        <h1 class="headline"><txp:title /></h1>
        <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 wraptag="ul" break="li">
        <a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a>
      </txp:article>

</txp:if_individual_article>

Ed. Adjusted based on maniqui’s comment below.

Last edited by Destry (2012-07-03 00:23:15)

Offline

#15 2012-07-02 23:52:59

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

This (in second line) isn’t correct

<txp:article section='<txp:section />'>

As txp:article is context-sensitive (contrary to txp:article_custom), it doesn’t have section attribute.

Regarding the error, my eyes can’t spot anything wrong (yet!).
Try debugging it by splitting code by “halves”.
In this case (assuming the error is currently happening in the chunk of code you pasted), I’d suggest to “empty” each branch of the conditional, and see when the error stops being triggered.

It may be that the error is somewhere else (for example, in the page template).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#16 2012-07-03 00:20:15

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

Well, I found what was causing the else errors. It was actually my navigation form. Good tip on blocking things out, maniqui.

Bad news is I still don’t have the right output with the form in focus of this thread.

I want this model:

If single article, output this...

{title}
{excerpt}
{body}

else output this...

{sticky article excerpt}
{list of live article titles}

But this code is actually outputting four live articles in full as…

{title}
{excerpt}
{body}

Offline

#17 2012-07-03 00:29:37

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

But this code is actually outputting four live articles in full as…

Is this happening when in individual article or when in article list? I’d guess it’s on the later one, but then, I couldn’t explain why it outputs the {title}, {excerpt} and {body}.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#18 2012-07-03 00:30:23

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

I have to hit the rack. Thanks for trying, maniqui.

Offline

#19 2012-07-03 00:33:40

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

maniqui wrote:

Is this happening when in individual article or when in article list?

Yes, the latter, when on the section landing: domain.tld/section.

I’m beginning to think my shit is corrupt.

Anyway, it’s 2:30am, I need to crash. I try again tomorrow.

Offline

#20 2012-07-03 05:26:26

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

Destry – the code is correct – on a fresh install I have used your code and get exactly what you want/should be getting.

The problem has to be with some other code elsewhere on the site which is causing the error.

Try it on a blank section with nothing else to see

Offline

#21 2012-07-03 06:39:42

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [Solved ]"Sticky" excerpt + article list at the same time

Destry wrote:

But this code is actually outputting four live articles in full as…

Destry, try and find that part of the code in the tag trace. If you can’t, post the full tag trace here.

Offline

#22 2012-07-03 07:05:28

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: [Solved ]"Sticky" excerpt + article list at the same time

Let us break down the code

<txp:if_individual_article>

      <txp:article> <!-- individual article -->
        <h1 class="headline"><txp:title /></h1>
        <p class="excerpt"><txp:excerpt /></p>
        <txp:body />
      </txp:article>

  <txp:else />

      <txp:article_custom status="sticky" section='<txp:section />' limit="1"> <!-- section page -->
         <p class="excerpt"><txp:excerpt /></p>         
      </txp:article_custom>

      <txp:article wraptag="ul" break="li">
        <a class="list-titles" href="<txp:permlink />" title="<txp:title />"><txp:title /></a>

or we can use a slightly more verbose code

<txp:if_article_list><!-- article list page, either section or category -->
<txp:variable name="categoryname" value='<txp:page_url type="c" />' /> <!-- detect if you are in a category page -->
<txp:if_variable name="categoryname" value=""><!-- section home page -->

      <txp:article_custom status="sticky" section='<txp:section />' limit="1"> // section front page
         <p class="excerpt"><txp:excerpt /></p>         
      </txp:article_custom>

<txp:else /><!-- category page -->
<txp:if_category name='<txp:category />'>

<!-- just in case you want some category specific content -->

</txp:if_category>
</txp:if_variable>
<txp:else /><!-- individual article page -->
      <txp:article>
        <h1 class="headline"><txp:title /></h1>
        <p class="excerpt"><txp:excerpt /></p>
        <txp:body />
      </txp:article>
</txp:if_article_list>
      </txp:article>

</txp:if_individual_article>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#23 2012-07-03 07:46:54

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

tye,

Yeah, I have no doubt the code is correct (maniqui is the tag master :)—though I’m not sure limit="1" is needed since there’s only one sticky article in the section anyway—but I can’t figure out why it’s out putting so wrong.

All,

This is a single column layout. There no categories involved right now. The page template is really simple and I’ve dissected each and every form. I’ve even fixed the navigation form. There are no errors showing up anywhere now.

The single article part of the conditional works fine (i.e., domain/tld/section/article-title outputs {title}, {excerpt} and {body} as desired), but both pieces under the else tag do nothing except make all ‘live’ articles in the section display. In fact, it makes no difference if I hide one, the other, or both of the article snippets under the else tag, the result is the same.

Of course, I could be looking at a green mamba and not know it, so let’s step back.

Page template code, top to bottom…

<txp:output_form form="tmpl-opener" />

<!-- main -->
<div role="main">
    <h1 class="section"><txp:section /></h1>
    <txp:output_form form="landing-articles" />
</div><!-- end of main -->

<txp:output_form form="tmpl-closer" />

The middle form, form="landing-articles", is what we’ve been talking about, this code. Following are the opener and closer template forms…

tmpl-opener:

<txp:output_form form="variables" />
<html class="no-js" lang="en">

<head>
   <txp:if_individual_article>
      <title><txp:article_custom><txp:title /></txp:article_custom> – <txp:section /> | <txp:site_name /></title>
   <txp:else />
      <title><txp:section /> | <txp:site_name /></title>
   </txp:if_individual_article>

<txp:output_form form="head-links" />
</head>

<!-- header -->
<header role="banner">
  <txp:output_form form="tmpl-header" />
</header>

<txp:output_form form="navigation" />

<body id="<txp:section />">
<div id="container">

As you can see there are a few more nested forms, but I’ve gone over them, so I’ll wait on that for now. This is the first time I’m using variables, however, so I don’t know if it’s okay to put it up at the top like that. The docs are not very clear; saying you can but not explicitly saying or showing where with an example.

tmpl-closer:

<footer role="contentinfo">
  <txp:output_form form="tmpl-footer" />    
</footer>

</div><!-- end of container -->

</body>
</html>

So, if we pretend we’re Txp and assemble all the pieces, it comes together like this…

<txp:output_form form="variables" />
<html class="no-js" lang="en">

<head>
   <txp:if_individual_article>
      <title><txp:article_custom><txp:title /></txp:article_custom> – <txp:section /> | <txp:site_name /></title>
   <txp:else />
      <title><txp:section /> | <txp:site_name /></title>
   </txp:if_individual_article>

<txp:output_form form="head-links" />
</head>

<!-- header -->
<header role="banner">
  <txp:output_form form="tmpl-header" />
</header>

<txp:output_form form="navigation" />

<body id="<txp:section />">
<div id="container">

<!-- main -->
<div role="main">
    <h1 class="section"><txp:section /></h1>
    <txp:output_form form="landing-articles" />
</div><!-- end of main -->

<footer role="contentinfo">
  <txp:output_form form="tmpl-footer" />    
</footer>

</div><!-- end of container -->

</body>
</html>

So far so good?

Ed.: Code in last block updated to fix a copy/paste mistake.

Last edited by Destry (2012-07-03 08:01:23)

Offline

#24 2012-07-03 08:10:06

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: [Solved ]"Sticky" excerpt + article list at the same time

Colak,

Your first “break down” block looks right, except maybe missing the closing if_individual_article tag. The other really isn’t needed because I’m not using categories here. It’s just a small section with four articles.

Els,

Thanks for the kick in the ass. I just realized I was looking only at tag errors, and not the actual trace. Bang! I’ll look that over and post if I don’t see anything obvious.

Offline

Board footer

Powered by FluxBB