Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Another developer question about plugins
Ok, how can I retrieve the current category when I am viewing an article?
I know I can use gps(‘c’) and a few other variations when I am on a category page. But I need to know the category the currently viewed article is on.
Any suggestions?
Eric
Offline
Re: Another developer question about plugins
Well, it depends what exactly you’re doing. If its a plugin thats used on a single article form you can use <code>$thisarticle[‘category1’]</code>. There’s some more info in this thread about the availability of $thisarticle and a nice writeup on it here.
If <code>$thisarticle</code> is not in scope you can use the global <code>$id</code> to do something like this:
<code>
$ca = safe_row(‘category1, category2’, ‘textpattern’, ‘id=’.$id);
extract($ca);
</code>
And then you’d have the ability to use <code>$category1</code> and <code>$category2</code>
Hope thats what you were looking for.
Offline
Re: Another developer question about plugins
Bingo… that will work. Now to finish the plugin…
Thanx again!
Eric
Offline