Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-26 10:39:17

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

different output depending on article existence

if there is article(s) in specific section display this else display nothing . can’t figure out myself…

Offline

#2 2009-11-26 11:02:28

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: different output depending on article existence

<txp:variable name="hasarticles" value='<txp:article_custom section=''<txp:section />'' limit="1" />' />
<txp:if_variable name="hasarticles" value="">
	Ain't.
<txp:else />
	Is.
</txp:if_variable>

Offline

#3 2009-11-26 11:29:21

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: different output depending on article existence

this code outputs nothing.
the specific section name is special and there is articles now.

Offline

#4 2009-11-26 12:17:52

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: different output depending on article existence

It should output either Ain’t or Is. Can’t be nothing. What do you see?

Offline

#5 2009-11-26 13:02:51

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: different output depending on article existence

i did put my code into wrong part, sorry. ;) yes, it’s working. but…
it still outputs the title h6 part if there is no articles in this section

my form

<txp:variable name="hasarticles" value='<txp:article_custom section=''<txp:section />'' limit="1" />' />
<txp:if_variable name="hasarticles" value="">
<txp:else />
<h6 class="eripakkumised">Eripakkumised</h6>
<txp:article_custom form="eripakkumised" limit="5" section="eripakkumised" />	
</txp:if_variable>

Offline

#6 2009-11-26 17:31:22

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

Re: different output depending on article existence

Are you displaying this on another section’s page? The first and the second article_custom tag should point to the same section, otherwise it’s testing for content in a different section ;) So either change the section attribute in the first tag to section="eripakkumised", or – if you need this for all ‘current’ sections – change the second one to section='<txp:section />'.

Offline

#7 2009-11-27 11:31:03

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: different output depending on article existence

the first suggestion works perfectly!m thank you all!

Offline

Board footer

Powered by FluxBB