Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-07-21 16:09:51
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
If Keywords...
I am setting up a system where users can input their favorite venues, some of which have websites while others dont. I would love to be able to use custom fields, except that certain sites have hyphens which dont work. With both body and excerpt fields occupied, my only option is to use the keywords field. I would like to have the article show the link but if the keywords field is blank, just show text.
I have come pretty close using the chh_if_data plugin..
<code><txp:chh_if_data><a href=”<txp:keywords /> “><txp:title /></a>
<txp:else /><txp:title /></txp:chh_if_data></code>
In theory this should work, but when I output an article with empty keywords field. I get this
<code><a href=” “>Title</a></code>
Any ideas?
Last edited by Ace of Dubs (2006-07-21 16:16:22)
Offline
#2 2006-07-21 17:10:31
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: If Keywords...
I think it’s because there are always data, because of the <txp:title /> tag inside the conditional. So I suppose the plugin checks if there are data in ‘keywords’ OR in ‘title’.
So you could start with
<txp:chh_if_data><a href="<txp:keywords />"></txp:chh_if_data><txp:title />, but then you run into the problem how to output the closing </a> only if ‘keywords’ has data.
And at the moment I don’t know how to do that :( There was a request for an ‘or/and’ attribute in the plugin thread, but there doesn’t seem to be a reply to that…
Edit:
Maybe something like this would work but it’s ugly:
<txp:chh_if_data><span style="display: none;"><txp:keywords /></span></a></txp:chh_if_data>
Last edited by els (2006-07-21 17:14:48)
Offline
#3 2006-07-21 17:17:36
- marios
- Archived Plugin Author

- Registered: 2005-03-12
- Posts: 1,253
Re: If Keywords...
Not certainly certain, but I think the basic mistake lies with the use of <code><txp:else /></code> in combination with the plugin conditional tag.
That’s I think why it doesn’t work, so you’d need another conditonal for it.
Have you checked that ?
If the above is true then you could set up an extra custom field that accompanies each article entry with a keyword entry and use an if custom field name conditional.
regards, marios
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
#4 2006-07-21 18:53:22
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: If Keywords...
@ Els
I dont understand how a span fixes the problem… also I am trying to avoid inline styles like the plague
@ Marios
I did try that approach and I get this:
<code><a href=”“>Title</code>
The link wont close itself this way.
Thinking more about this, my problem would also be solved if the keywords field could parse Textile. May just have to do some hacking to get the desired result..
Offline
#5 2006-07-21 18:59:51
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: If Keywords...
Ace of Dubs wrote:
I dont understand how a span fixes the problem… also I am trying to avoid inline styles like the plague
You need the txp:keywords tag for chh_if_data to regocnize if it has data, but you don’t want to display it again. You could also give the span a class and put the display:none; in the CSS. But, as I said, it’s kind of ugly.
my problem would also be solved if the keywords field could parse Textile
upm_textile maybe?
Last edited by els (2006-07-21 19:02:53)
Offline
#6 2006-07-21 22:17:50
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: If Keywords...
That works beautifully!
Thanks for the link :)
Offline
Pages: 1