Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: having urls in custom fields
Hi all,
I have the following code:
<h4><a href="<txp:site_url /><txp:php>echo strtolower(<txp:custom_field name="article_form" />);</txp:php>
"><txp:custom_field name="article_form" /></a></h4>
which is obviously incorrect.
Basically, I have a custom field named “article_form” (I am using the glz_custom_fields plugin), and it is a radio type with two options – both have a first letter that is capitalised. I am trying to create a link, using the appropriate field, but with all letters in lowercase.
Can someone please suggest a fix?
“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower
Offline
#14 2009-11-03 09:19:22
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: having urls in custom fields
I think its a problem with nested quotes. Try this:
<h4><a href='<txp:site_url /><txp:php>echo strtolower(<txp:custom_field name="article_form" />);</txp:php>
'><txp:custom_field name="article_form" /></a></h4>
(note the single quotes)
edit: Doh! Never post when still not wide awake. Please ignore this answer and read below
Last edited by redbot (2009-11-03 09:36:02)
Offline
Re: having urls in custom fields
Use the function name instead of the tag inside PHP blocks. Like this:
<h4><a href="<txp:site_url /><txp:php>echo strtolower(custom_field(array('name' => 'article_form')));</txp:php>
"><txp:custom_field name="article_form" /></a></h4>
I keep meaning to add this to Textbook somewhere. Must find a slot for it one day.
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
Offline
Re: having urls in custom fields
@Bloke,
Brilliant, works like a charm. Thank you!
“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower
Offline