Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-04-09 09:34:39

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

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

What’s the most elegant way to hide the <hr> if there are no articles?

<txp:article_custom section="articles" category="berichten" form="single_nolink_important" sort="" wraptag="" class="" break="" limit="2" label="Ingekomen berichten" labeltag="h3" />
<hr>

Last edited by RedFox (2015-04-09 09:36:24)

Offline

#2 2015-04-09 10:51:12

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

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

Have you already tried break="hr"? Edit: I’m asking cause I can’t tell with certainty whether the hr is placed after the article or before. (Resolved itself and not well thought out.)

You can of course also put that hr inside your single_nolink_important form.

Last edited by uli (2015-04-09 11:11:04)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2015-04-09 11:02:07

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

If you only want one hr after the two articles you can use a variable

<txp:variable name="hrv" value='<txp:article_custom section="articles" category="berichten" form="single_nolink_important" sort="" wraptag="" class="" break="" limit="2" label="Ingekomen berichten" labeltag="h3" />' />
<txp:if_variable name="hrv" value="">
<txp:hide>no articles</txp:hide>
<txp:else />
<txp:variable name="hrv" />
<hr>
</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

#4 2015-04-09 11:02:18

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

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

uli wrote #289824:

Have you already tried break="hr"?

Yes, but strange enough that doesn’t work … it doesn’t render <hr>‘s … and there are no error notifications too … !?

BTW … it’s not precisely what I want. If there are 2 articles … 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.

Offline

#5 2015-04-09 11:04:47

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

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

Joop, I’ve amended my first post. (But maybe you can also go with Yiannis’ solution.)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#6 2015-04-09 11:09:23

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

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

Off course … variable’s … pffff.

Last edited by RedFox (2015-04-09 11:12:25)

Offline

#7 2015-04-09 11:11:54

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

Whoops, I did not notice that there was a form there. You might not need the code I posted as it might be an overkill. Could you tell us what you have in that form?


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

Offline

#8 2015-04-09 11:13:36

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

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

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

Offline

#9 2015-04-09 11:15:48

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 the variable will work as I cannot See a way to include it in the form so as to appear only once.


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

Offline

#10 2015-04-09 11:20:59

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

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

RedFox wrote #289823:

What’s the most elegant way to hide the <hr> if there are no articles?

How about wrapping the <hr> tag inside a txp:if_last_article tag in your form? Does that work?


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

#11 2015-04-09 11:45:48

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

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

Yiannis … did you perhaps made a typo in your first post … ;-)

Now it’s working … off course > tvdiever.nl … top sidebar.

Bloke … also nice … wait a moment please.

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

Offline

#12 2015-04-09 11:53:45

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

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

Bloke … it does the job too … after some tweaking:

HTML:

<txp:article_custom section="articles" category="berichten" form="single_nolink_important" sort="" wraptag="" class="" break="hr" limit="2" label="" labeltag="" />

Form:

<txp:if_last_article>
<h3>Ingekomen berichten</h3>
<div class="article important">
<h1 class="entry-title"><txp:title /></h1>
<txp:body />
</div>
<hr>
<txp:else />
<div class="article important">
<h1 class="entry-title"><txp:title /></h1>
<txp:body />
</div>
</txp:if_last_article>

Offline

Board footer

Powered by FluxBB