Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-06-20 16:07:41

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

How to omit data from articles posted at midnight?

hello forum,

i asume i have a pretty esoteric problem. for my photofestival website i have about 60 exhibitions each of which is an article. some exhibitions have a vernissage, some not.

i use <txp:posted > to output the date and time of the vernissage:

<h4>Vernissage</h4>
<p><txp:posted format="%d.%m.%Y,&ensp;%H:%M" />&ensp;Uhr</p>

works fine, but obviously if there is no vernissage, than there is no time set and it outputs 00:00 Uhr.

does anybody have an idea how i could omit the whole snippet in case time is set to 00:00? i was thinking of a solution with <txp:variable > but i’m lacking the programmer skills to tell the @<txp:if_variable > tag “if time is 00:00 do nothing, else output my snippet”.

so any idea or hint is much appreciated. thanks for your time.

christoph

Offline

#2 2012-06-20 16:37:20

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 595
Website

Re: How to omit data from articles posted at midnight?

<txp:variable name="vernissage_time"><txp:posted format="%d.%m.%Y,&ensp;%H:%M" /></txp:variable>

<txp:if_variable name="vernissage_time" value="00:00"><!-- make double-sure that's exactly correct! -->
<!-- do nothing -->
<txp:else />
<h4>Vernissage</h4>
<p><txp:posted .... etc.... ></p>
</txp:if_variable>

Last edited by maruchan (2012-06-20 22:13:58)

Offline

#3 2012-06-20 16:57:29

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: How to omit data from articles posted at midnight?

hi maruchan,

thank you. for some weird reason this produces a tag error for <txp:else />. can’t see why, as the part before the else-statement is parsed (“Keine Vernissage” in case it’s 00:00).

<txp:variable name="vernissage_time"><txp:posted format="%H:%M" /></txp:variable>
		<txp:if_variable name="vernissage_time" value="00:00">
			<p>Keine Vernissage</p>
			<txp:else />
			<h4>Vernissage</h4>
			<p><txp:posted format="%d.%m.%Y,&ensp;%H:%M" />&ensp;Uhr</p>
		</txp:if_variable>

tag trace:

		<txp:article>
			<txp:title />
			<txp:custom_field name="Kuenstler" />
			<txp:custom_field name="Galerie" />
			<txp:custom_field name="Strasse_Nr" />
			<txp:custom_field name="PLZ" />
			<txp:custom_field name="Stadt" />
			<txp:custom_field name="Telefon" />
			<txp:custom_field name="Internet" />
			<txp:custom_field name="Internet" />
			<txp:posted format="%d.%m." />
			<txp:expires format="%d.%m." />
			<txp:variable name="vernissage_time">
				<txp:posted format="%H:%M" />
			</txp:variable>
			<txp:else />
				Fehler im Tag: <txp:else /> -> Textpattern Warning: Unbekannter Tag  on line 1202
			<txp:posted format="%d.%m.%Y,&ensp;%H:%M" />
		</txp:article>

it says “unknown tag on line 1202 …

Last edited by colak (2012-06-21 04:45:52)

Offline

#4 2012-06-20 17:09:09

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Re: How to omit data from articles posted at midnight?

HI

there must be a n underscore for txp_variable, it s missing.

Offline

#5 2012-06-20 17:12:53

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: How to omit data from articles posted at midnight?

hi, thank you both very much. now it works. it’s the details, that matter – as always ;-)

Offline

#6 2012-06-20 19:03:12

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

Re: How to omit data from articles posted at midnight?

there is also an underscore missing from the post here

It should be:

		<txp:if_variable name="vernissage_time" value="00:00">

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

Offline

#7 2012-06-20 22:14:31

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 595
Website

Re: How to omit data from articles posted at midnight?

Fixed my example for future TXPers. :-)

Offline

Board footer

Powered by FluxBB