Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2013-05-31 08:04:44
- whpjm
- Member
- Registered: 2009-04-24
- Posts: 15
if statement
hello
i have this code
<table>
<tr>
<td><img src=”<txp:custom_field name=“custom1” />”></td>
<td>
<h2><txp:title /></h2>
<txp:permlink class=“terug”>bekijk de foto’s >></txp:permlink>
<p>Fotografie: <txp:custom_field name=“custom2” /></p>
</td>
</tr>
</table>
mine question is:
when title = “Omroep Zeeland”
then will i not show <txp:permlink class=“terug”>bekijk de foto’s >></txp:permlink>
<p>Fotografie: <txp:custom_field name=“custom2” /></p>
how do i make an if-statement ?
with greetings
wilbert
Offline
Re: if statement
whpjm wrote:
when title = “Omroep Zeeland”
how do i make an if-statement ?
If it’s only one article, and you know it’s id, you can exclude it by: <txp:if_article_id>
-kees
…met groet uit zeeland
Offline
Re: if statement
whpjm wrote:
how do i make an if-statement ?
Another way is to use txp:variable and txp:if_variable, a bit like this:
<txp:hide> Assign the title to a variable called my_title </txp:hide>
<txp:variable name="my_title"><txp:title /></txp:variable>
<table>
<tr>
<td><img src="<txp:custom_field name="custom1" />"></td>
<td>
<h2><txp:variable name="my_title" /></h2>
<txp:if_variable name="my_title" value="Omroep Zeeland">
<txp:hide> Do not display the permlink </txp:hide>
<txp:else />
<txp:permlink class="terug">bekijk de foto's >></txp:permlink>
<p>Fotografie: <txp:custom_field name="custom2" /></p>
</txp:if_variable>
</td>
</tr>
</table>
But kees-b’s version is neater if it’s only going to be one article and you don’t mind using article IDs.
EDIT: another approach might be to use txp:if_custom_field, assuming that you won’t want to display the content if custom2
is empty. That means the logic would work across articles instead of being constrained to one particular article.
Last edited by Bloke (2013-05-31 08:28:49)
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
Online
#4 2013-05-31 09:59:35
- whpjm
- Member
- Registered: 2009-04-24
- Posts: 15
Re: if statement
thanks!!
Offline
Pages: 1