Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-30 10:30:08

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Using if variable instead of if data plugin?

I heard you can use the if variable tag instead of the if data plugin. How is this done?

Offline

#2 2008-11-30 15:05:39

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: Using if variable instead of if data plugin?

<txp:variable name="has_output" value='<txp:article_custom id="22" />' />

<txp:if_variable name="has_output">
  <p>There is article with id=22</p>
<txp:else />
  <p>No article with id=22</p>
</txp:if_variable>

The idea, i think, is clear. For chacking large code snippets, you can use forms in variable name


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#3 2008-11-30 15:16:43

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Using if variable instead of if data plugin?

I’m not sure that would work Victor. You need to check the “value”. Something like this does work though cuz I’m using it:-

<txp:variable name="website" value='<txp:comment_web />' />
<txp:if_variable name="website" value="">
<txp:else />
<dt><span>Website</span></dt>
<dd><a href="http://<txp:comment_web />"><txp:comment_web /></a></dd>
</txp:if_variable>

Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#4 2008-11-30 16:07:28

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

Re: Using if variable instead of if data plugin?

thebombsite wrote:

I’m not sure that would work Victor. You need to check the “value”.

value is by default set to unset (empty).

Offline

#5 2008-11-30 16:21:29

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Using if variable instead of if data plugin?

It may be for the <txp:variable /> tag but you still need to check the “value” in the <txp:if_variable> tag, in other words using Victor’s example:-

<txp:variable name="has_output" value='<txp:article_custom id="22" />' />
<txp:if_variable name="has_output" value="">
<p>No article with id=22</p>  
<txp:else />
<p>There is article with id=22</p>
</txp:if_variable>

Last edited by thebombsite (2008-11-30 16:35:25)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#6 2008-11-30 16:51:14

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

Re: Using if variable instead of if data plugin?

thebombsite wrote:

It may be for the <txp:variable /> tag but you still need to check the “value” in the

It still is unset by default, (note: i just said it is unset, nothing more :D) atts array’s value -index returns unset, if it ain’t set. What will you think it will return if it is checked with isset()? False or true? ;)

Edit. And, yes I meant the if_variable, plus I did not disagree in anyhow with you ;D

Last edited by Gocom (2008-11-30 16:54:09)

Offline

Board footer

Powered by FluxBB