Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2015-04-09 11:54:28

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 811
Website

Re: How to hide <hr> if there are no articles ... ?

Oké, thanks all. Shall we vote?

BTW … I’m always hesitant to ask such simple questions, but hé, I’m learning so much … :))

Last edited by RedFox (2015-04-09 11:57:53)

Offline

#14 2015-04-09 12:05:20

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

Re: How to hide <hr> if there are no articles ... ?

I guess that Oleg is needed here to tell us which one uses less memory or even suggest an even more economic solution:)


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

Offline

#15 2015-04-09 12:11:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,779
Website GitHub

Re: How to hide <hr> if there are no articles ... ?

RedFox wrote #289834:

it does the job too … after some tweaking:

If it works, great, though I’m a bit confused. You said “I get a <hr> between article 1 and 2 … and I only want a <hr> after 1, 2, etc. articles. And no <hr> if there are none articles.”

Isn’t that:

  • Article 1
  • Article 2
  • <hr>

and nothing output at all if there are no articles? In which case, why do you have break="hr" in your article_custom tag?

If this is what you want:

  • Article 1
  • <hr>
  • Article 2
  • <hr>

Then you don’t need the break attribute: set it to break="", hard-code the <hr> at the end of the form and you’re done.

For the first scenario (although untested) I would expect the following to work:

<txp:article_custom
    section="articles"
    category="berichten"
    form="single_nolink_important"
    sort=""
    break=""
    limit="2" />

With form:

<txp:if_last_article>
   <h3>Ingekomen berichten</h3>
</txp:if_last_article>

<div class="article important">
   <h1 class="entry-title"><txp:title /></h1>
   <txp:body />
</div>

<txp:if_last_article>
   <hr>
</txp:if_last_article>

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#16 2015-04-09 12:18:50

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 811
Website

Re: How to hide <hr> if there are no articles ... ?

Bloke … sorry. The <hr> in the article tag was a leftover from the first suggestion (Uli’s) … it’s gone now. And your last snippet is elegant too … :)

After some tweaking:

<txp:if_first_article>
<h3>Ingekomen berichten</h3>
</txp:if_first_article>

<div class="article important">
<h1 class="entry-title"><txp:title /></h1>
<txp:body />
</div>

<txp:if_last_article>
<hr>
</txp:if_last_article>

Last edited by RedFox (2015-04-09 12:30:46)

Offline

Board footer

Powered by FluxBB