Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2006-07-11 20:27:07
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
My apologies…for the sake of not confusing anyone, I was rolling with jhyde’s example. In reality I am using custom_3, which is named HCM. That’s the catalog prefix for all releases. It gets plugged in with a 3-digit number whenever there is a new record or a licensing/review of said record. This way all articles about the release gets shown under “Related News”
You can see a working example here:
Link
I have achieved the desired effect, but it requires the user to modify the release number on a per article basis in the following code:
<code><txp:chh_article_custom category=“Compilations,Reviews” HCM=”###” /></code>
My problem page is located here:
Link
Even though I already have an article with the HCM field set to “006”, it still doesn’t show up
Here is the PHP I am using in the (misc) form:
<code> <txp:php>
global $thisarticle;
if (!empty($thisarticle[‘custom_3’]))
{
echo chh_article_custom(array(
‘category’ => ‘Compilations,Reviews’,
‘HCM’ => $thisarticle[‘custom_3’],
‘wraptag’ => ‘li’
));
}
</txp:php></code>
If there is no fix then I suppose it’s no big deal and my clients can work with what I’ve hacked together. Still not giving up hope for a more elegant solution tho..
Offline
#14 2006-07-11 20:29:09
- jhyde
- New Member
- Registered: 2006-07-10
- Posts: 5
Re: Problems using a custom field within another txp tag
Mary,
Thanks to you I am very close to a solution. I am getting an error
tag_error <txp:php> -> Warning: Missing argument 2 for file_download_link() on line 1931
I’m guessing this is because I am using a container tag (file_download_link). Since I am calling the tag handler directly, I’m guessing I need something in there to tell it it’s a container tag.
Here is the code:
<code>
<ul><li>
<txp:php>
global $thisarticle;
The source that it outputs:
<code>
<ul><li>
<a href=“http://localhost/txp/index.php?s=file_download&id=6”></a>
Warren Miller show reel (.zip) [5.22mb]</txp:file_download_link>
</li></ul>
</code>
The ending “a”(<code></a></code>) tag should be where the <code></txp:file_download_link></code> is.
Thanks again for all your help.
Offline
#15 2006-07-12 02:04:17
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Problems using a custom field within another txp tag
For the second one:
<ul><li>
<txp:php>
global $thisfile;
$atts = array('id' => $thisfile['id']);
$thing = '<txp:file_download_description /> [<txp:file_download_size format="auto" decimals="2" />]';
echo file_download_link($atts, $thing);
</txp:php>
</li></ul>
For the first one, as far as I can tell, that should work, but I don’t know the inner workings of that plugin to have certainty. I’ve gotta go out for the moment, but if I come back and you’ve not gotten any further, then I’ll install the plugin myself and figure it out. :)
Offline
#16 2006-07-12 12:02:30
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
Hmmmmmm….
Not so sure if it’s a plugin issue. I just tried it with plain old article_custom and that’s not doing the trick either. Makes me wish there was a plugin to parse tags within tags.
Anyway, I really appreciate the assist.. you always do go above and beyond the call of duty. :)
Offline
#17 2006-07-12 15:32:39
- jhyde
- New Member
- Registered: 2006-07-10
- Posts: 5
Re: Problems using a custom field within another txp tag
Above and beyond is right! Mary, a million thanks. My pages are now working correctly thanks to you. For those interested here is the code snippet I ended up using:
<code>
<txp:php>
global $thisarticle;
if (!empty($thisarticle[‘file_download_id’]))
{
$atts = array(‘id’=>$GLOBALS[‘thisarticle’][‘file_download_id’]);
$thing = ‘<txp:file_download_description /> [<txp:file_download_size format=“auto” decimals=“2” />]’;
echo file_download_link($atts, $thing);
}
</txp:php>
</code>
Where <code>file_download_id</code> is the name of my custom field.
Offline
#18 2006-07-16 01:48:52
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
UPDATE:
So it turns out that the chh_related plugin didn’t do the trick. I thought it did until I started making a bunch of articles and realized that it was not filtering the way I expected. It found article by custom field but ignores categories. So it’s back to square one, here.
The desperation sets in as I begin to peruse zem’s guide to developing plugins. One look at this tutorial (and php.net) is making me realize I wont be able to make my first plugin in time for my deadline this week..ha
But I do have a Paypal account and would gladly support the efforts of anyone who can help me solve this riddle.
The request seems simple enough. Tell TXP to retrieve a list of articles that meet both of the following conditions
1. Shares the same value of current article’s custom_3 (or in my case “HCM”)
2. Belongs to Category 1, 2 or 3 (These are categories other than the current article)
Any takers? (Tries hard not to look at Mary)
Last edited by Ace of Dubs (2006-07-16 01:52:14)
Offline
#19 2006-07-16 02:32:12
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Problems using a custom field within another txp tag
Waaaaiit a minute…
Belongs to Category 1, 2 or 3 (These are categories other than the current article)
What do you mean? Above your example stated it should have the categories, “Compilations” and “Reviews”. ?
Offline
#20 2006-07-16 02:46:22
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Problems using a custom field within another txp tag
Sorry, the previous request was just one example and I have since re-organized the content a bit… Let me explain better.
The site is for a record label and each release gets an article… on the release page I would love to have lists of articles that match the release catalog# (HCM which is custom_3) and show the categories like so:
bc..
h4. Related News
(Show related Compilations and Licensings)
h4. Feedback
(Show related Reviews and DJ Charts)
To clarify, I am not looking for articles that have BOTH categories selected in Cat1 Cat2… rather, the default behavior of listing all articles from each category (filtered by the custom field of course) is what I am after
Does this make sense?
Offline