Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-12-11 01:34:54

edburdo
Member
Registered: 2004-09-20
Posts: 79
Website

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

#2 2004-12-11 02:43:20

wilshire
Plugin Author
From: Akron, Ohio
Registered: 2004-08-27
Posts: 656
Website

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

#3 2004-12-11 15:37:33

edburdo
Member
Registered: 2004-09-20
Posts: 79
Website

Re: Another developer question about plugins

Bingo… that will work. Now to finish the plugin…

Thanx again!


Eric

Offline

Board footer

Powered by FluxBB