Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-12-29 16:53:15
- TWD
- Member
- Registered: 2009-09-10
- Posts: 14
if_variable and comments_web
Hello again! :)
I have been using this snippet in my comments form:
<a href="<txp:comment_web />" rel="nofollow"><txp:comment_name link="0" /></a>
I realized that this would produce links even for people who didn’t input a website, so I tried to use if_variable
to avoid that.
I declared <txp:variable name="web" value='<txp:comment_web />' />
at the start of the comments form, and then used this:
<txp:if_variable name="web"><a href="<txp:comment_web />" rel="nofollow"><txp:comment_name link="0" /></a>
<txp:else /><txp:comment_name link="0" /></txp:if_variable>
This still results in a link for comment authors that left no website address, however. If I understand the documentation correctly, that means that txp:comments_web
isn’t empty even if the author leaves no website… so is there any way I can use the anchor tag and avoid links to people who don’t give a website? Thanks!
Last edited by TWD (2009-12-29 16:54:04)
Offline
Re: if_variable and comments_web
Hi TWD you do not need the rel="nofollow"
. In Admin>Preferences>Advanced, there is an option: Apply rel="nofollow" to comments? - Yes No
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#3 2009-12-29 17:07:24
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_variable and comments_web
If I understand the documentation correctly, that means that txp:comments_web isn’t empty even if the author leaves no website
More exactly, it means that as soon as you have set the variable (with <txp:variable />
), it exists. So with <txp:if_variable name="web">
you are only checking for its existance. You should instead check if it’s empty or not:
<txp:if_variable name="web" value="">
<txp:comment_name link="0" />
<txp:else />
<a href="<txp:comment_web />"><txp:comment_name link="0" /></a>
</txp:if_variable>
Edit: removed the rel="nofollow"
, colak already pointed out why ;)
Last edited by els (2009-12-29 17:08:51)
Offline
Re: if_variable and comments_web
The easiest way is to use <txp:comment_name />
as it is. What it does:
If email address is supplied and allowed to be viewed, an email link is created. Otherwise, if a website is entered, the website URL is used. If neither is supplied, name displays as plain text.
Check the Wiki entry…
From my comments
form on TXP Tips:
<p><txp:comment_name /><br />
Output is like on this tip
Offline
#5 2009-12-29 17:10:24
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_variable and comments_web
Offline
Re: if_variable and comments_web
Let me enjoy this moment – the first and only time I have better advice than Els! ;-)
Seriously, the TXP comments system is quite obtuse and hard to understand sometimes.
Offline
#7 2009-12-29 19:56:18
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_variable and comments_web
jstubbs wrote:
Let me enjoy this moment – the first and only time I have better advice than Els! ;-)
Don’t worry, I’m sure it will happen again ;) I just focused on the variable/if_variable tags and forgot to look at the context :)
Offline
#8 2009-12-29 21:57:12
- TWD
- Member
- Registered: 2009-09-10
- Posts: 14
Re: if_variable and comments_web
Thanks guys! I was going through all this because of I wanted nofollow in there (and completely forgot about the admin option), actually, so I guess that resolves everything! :)
Last edited by TWD (2009-12-29 21:57:47)
Offline
Pages: 1