Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2005-06-15 21:25:45
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
Simple, no.
A simpl*er* method would be to get yourself a diff program, like WinMerge or CSDiff (Google for them) and then you can see all the differences in files.
Offline
#17 2005-06-15 21:34:24
- aboswell
- Member
- Registered: 2004-11-08
- Posts: 26
Re: upm_category_title
thanks Mary-
I think that I will just back everything up and then make the changes again by hand. I wouldn’t even do it if I didn’t want this feature.
Offline
#18 2005-06-28 03:16:43
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
v.0.4.2
Offline
Offline
#20 2005-07-13 02:07:52
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
v.0.4.3
Offline
Re: upm_category_title
Hey mary,
I am now wanting to output the name for category1 and category2. Could you give me your previous version that had upm_category1 and upm_category2 in it so I can adapt it to my needs.
Thanks.
Refresh Dallas and other Refreshing Cities.
Offline
#22 2005-08-19 19:49:14
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
Er, the plugin never output the names, only titles. The built-in tags output the titles for category1 and category2 now. ???
Offline
Re: upm_category_title
Yea I know, I want to go backwards and output names not titles so I can create my own links. I thought I could use your plugin and change the code a bit to suit my needs.
Refresh Dallas and other Refreshing Cities.
Offline
#24 2005-08-19 20:06:58
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: upm_category_title
Oh I see. Unfortunately, I only just started using svn to manage my own development, so I don’t have previous versions anymore. :(
But, the good news is all you need is
<pre><code>function category1_name($atts)
{
return $thisarticle[‘category1’];
}
function category2_name($atts)
{
return $thisarticle[‘category2’];
}</code></pre>
I’ve been thinking about creating a plugin that allows users to create and use their own tags, but don’t want to create a whole plugin. I know I’d like use it myself, since if all you’re doing is a miniscule change, its not worth the effort of compiling it.
Offline
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