Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-11-03 05:57:49

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

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

#15 2009-11-03 09:19:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

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

#16 2009-11-03 11:39:32

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

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

Board footer

Powered by FluxBB