Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: upm_category_title
Thanks mary, is this all the code I need to compile the plugin? Or do I paste this in your plugin? I am not too knowledgeable in php so any help is very appreciated.
Refresh Dallas and other Refreshing Cities.
Offline
#26 2005-08-19 21:28:19
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
Okay, just paste this into the end of the plugin.
<pre><code>function upm_category1_name()
{
return $thisarticle[‘category1’];
}
function upm_category2_name()
{
return $thisarticle[‘category2’];
}</code></pre>
That gives you the tags <txp:upm_category1_name />
and <txp:upm_category2_name />
.
(Edit: Corrected.)
Last edited by Mary (2005-08-19 22:13:25)
Offline
Re: upm_category_title
It’s not giving me any output. I am using it in a form and it is just blank.
Refresh Dallas and other Refreshing Cities.
Offline
#28 2005-08-19 22:14:07
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
Sorry, that code isn’t quite right. I’ve corrected it. Make sure you’re using it in an article form.
Offline
Re: upm_category_title
Sorry Mary It still doesn’t seem to be working here is how I am using it in an article form:
<code><txp:if_individual_article>
<p class=“post-info-single”>Posted: <txp:posted />
<txp:if_article_section name=“Commentary”>| Author: <a href=”/about/<txp:upm_category2_name />”><txp:category2 /></a></txp:if_article_section></p>
<h2><txp:title /></h2>
<txp:body />
<p class=“paging”> <txp:link_to_next>« Newer</txp:link_to_next> <txp:link_to_prev>Older »</txp:link_to_prev></p>
</txp:if_individual_article></code>
and here is how your code is placed in the upm_category_title plugin:
<code>function upm_category_title($atts = ‘’)
{
global $c, $permlink_mode;
extract(lAtts(array(
‘name’ => false,
‘wraptag’ => false,
‘id’ => false,
‘class’ => false,
‘link’ => ‘no’,
‘link_section’ => ‘no’
), $atts));
// thanks Joshua
if ($name)
{
$c = $name;
}
if ($c)
{
$rs = safe_row(“title”,“txp_category”,“name=’$c’ limit 1”);
if ($rs)
{
$cat = $rs[‘title’];
if ($link 'yes')
{
if ($permlink_mode ‘messy’)
{
$cat = href($cat, ‘?c=’.urlencode($c));
}
else
{
if ($link_section == ‘yes’)
{
global $s;
$cat = href($cat, hu.strtolower(urlencode($s)).’/’.strtolower(urlencode($c)));
}
else
{
$cat = href($cat, hu.strtolower(gTxt(‘category’)).’/’.strtolower(urlencode($c)));
}
}
}
if ($wraptag)
{
$id = ($id != ‘’) ? ‘ id=”’.$id.’”’ : $id;
$class = ($class != ‘’) ? ‘ class=”’.$class.’”’ : $class;
return tag($cat, $wraptag, $id.$class);
}
return $cat;
}
}
return ‘’;
}
function upm_category1_name()
{
return $thisarticle[‘category1’];
}
function upm_category2_name()
{
return $thisarticle[‘category2’];
}</code>
It doesn’t output anything, like there is nothing there. I have txp installed with a prefix on the database if that matters.
Last edited by tinyfly (2005-08-22 13:09:14)
Refresh Dallas and other Refreshing Cities.
Offline
#30 2005-08-22 17:14:37
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
That’s weird, that should work. What happens if you use this?
<code><txp:php>
echo $thisarticle[‘category1’];
</txp:php></code>
Offline
Re: upm_category_title
Using your upm_category2_name with txp in debugging status I get “undefined variable thisarticle” error.
Using the echo statment above it works fine.
Refresh Dallas and other Refreshing Cities.
Offline
#32 2005-08-22 19:03:38
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
Oh DUH…
<pre><code>function upm_category1_name()
{
global $thisarticle;
return $thisarticle[‘category1’];
}
function upm_category2_name()
{
global $thisarticle;
return $thisarticle[‘category2’];
}</code></pre>
I know what I’m doing, really…
Offline
Re: upm_category_title
Perfect, works great now. Thanks mary.
Refresh Dallas and other Refreshing Cities.
Offline
#34 2005-11-24 05:12:37
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
v.0.4.5
Offline
Re: upm_category_title
mary is no longer maintaining this plugin – a copy of the last release is available here from upm-plugins archive
Refresh Dallas and other Refreshing Cities.
Offline