Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-07-10 23:40:35
- jhyde
- New Member
- Registered: 2006-07-10
- Posts: 5
Problems using a custom field within another txp tag
I can’t seem to get the following article form to work.
<code>
<ul>
<li>
<txp:file_download_link id=”<txp:custom_field name=“file_download_id” />” >
<txp:file_download_description /> [<txp:file_download_size format=“auto” decimals=“2” />]
</txp:file_download_link>
</li>
</ul>
</code>
The html output looks something like:
<code>
<ul><li><a href=“http://localhost/txp/index.php?s=file_download&id=”></a>” > []</txp:file_download_link></li></ul>
</code>
removing the custom field tag and entering an integer works just fine of course. Displaying the custom field outside of the txp tag works just fine. BTW the value for the custom field is an integer (I was working with 3, 4, and 5).
Any help or insight would be greatly appreciated.
Offline
Re: Problems using a custom field within another txp tag
hi jhyde,
check the FAQs
There is one named “Can I use tags inside tags?” that explain that yu can’t use TxP tags inside TxP tags.
Offline
#3 2006-07-11 00:12:09
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Problems using a custom field within another txp tag
In addition, custom fields are only for articles, so they only work from article forms at present.
Offline
#4 2006-07-11 00:26:51
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
It would be nice if you could though :)
Offline
#5 2006-07-11 00:45:33
- jhyde
- New Member
- Registered: 2006-07-10
- Posts: 5
Re: Problems using a custom field within another txp tag
I’ve read the FAQ, and I am now trying to call the tag handler function directly to populate the attribute value. Here is the code:
<code>
<ul><li>
<txp:php>
echo file_download_link(
array(‘id’=>$GLOBALS[‘pretext’][‘custom_4’])
);
</txp:php>
<txp:file_download_description /> [<txp:file_download_size format=“auto” decimals=“2” />]</txp:file_download_link>
</li></ul>
</code>
So far, this does NOT work.
This is definitely in a article form. I’m PHP illiterate so… I did look into the database and the field I want to display as the attribute is labelled custom_4.
Thx
Offline
#6 2006-07-11 01:28:52
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Problems using a custom field within another txp tag
Do $GLOBALS['thisarticle']['custom_4']
Offline
#7 2006-07-11 10:40:56
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
Wow…I had no idea you could do this with PHP. I need to read that FAQ more often!
In my case, I am trying to get the contents of “custom_4” to spill into the following attribute dynamically:
<code><txp:chh_article_custom wraptag=“li” category=“Books,Reviews” custom_4=”<txp:custom_field name=“custom_4” />” /></code>
My first attempt at PHP has proved very humbling:
<code><txp:php>
echo chh_article_custom
(array(‘custfield’=>$GLOBALS[‘thisarticle’][‘custom_4’]) );
(array(‘category’=>$GLOBALS[‘thisarticle’][‘Books,Reviews’]) );
(array(‘wraptag’=>$GLOBALS[‘thisarticle’][‘li’]) ); </txp:php></code>
The above is sitting inside an article form which I am calling up from inside an article. How can I make it work?
Last edited by Ace of Dubs (2006-07-11 12:08:36)
Offline
#8 2006-07-11 17:22:52
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Problems using a custom field within another txp tag
<txp:php>
global $thisarticle;
if (!empty($thisarticle['custom_4']))
{
echo chh_article_custom(array(
'category' => 'Books,Reviews',
'custfield' => $thisarticle['custom_4'],
'wraptag' => 'li'
));
}
</txp:php>
:)
Last edited by Mary (2006-07-11 18:15:32)
Offline
#9 2006-07-11 17:44:57
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
Hey, that’s encouraging how close I was! :D
Your version is prettier though, sad to say it doesn’t work yet
Details:
Right now I am outputting this PHP in a misc form from inside an article.
Everything parses just fine, except that I get a list of articles that have custom_4 filled out, regardless of the content.
My aim is only to call up those articles whose values for custom_4 are identical to the current article. Is this possible?
Edit: I deleted one of the categories to see if the other arrays were working..apparently, the custom fields are not working at all and no links show up.
Last edited by Ace of Dubs (2006-07-11 18:13:31)
Offline
#10 2006-07-11 18:16:19
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Problems using a custom field within another txp tag
I updated the code above. Remember to change custfield to the name/title of your custom_4 field.
Offline
#11 2006-07-11 18:36:09
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
Just tried it and now I get zero output, so then I tried putting my custom_4 title in the (!empty($thisarticle[‘custom_4’])) and I got the same unfiltered list I got before. PHP sure is funky..
Last edited by Ace of Dubs (2006-07-11 18:36:38)
Offline
#12 2006-07-11 19:48:04
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Problems using a custom field within another txp tag
If you’re getting zero output, then chances are that your article either doesn’t have a value in your custom_4 field, or you might’ve misspelled your custom field’s name. What is your custom field’s name?
Offline