Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-08-09 18:13:47

walter976
New Member
Registered: 2009-08-02
Posts: 7

if_author function problem

Hello,

I’m just starting to write my first plugin and I would like to execute some code only if the called page is the result of an article search by a specific author’s name.

I found the function if_author which seems exactly what I need but I’m not able to make it working, anyone can help please?

Offline

#2 2009-08-09 19:33:52

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: if_author function problem

walter976 wrote:

I found the function if_author which seems exactly what I need but I’m not able to make it working, anyone can help please?

And where do you get the data for the author exactly? Hard to know what your are doing. The code that you want to execute in simplest case, is just an simple conditional statement.

Inside article context we can do things, like:

global $author;
if($author != $thatwewant) return ''; // not that.
// Continue.

The if_author function is a tag container function. You can use it, but better is to use the same methods that the tag uses, like the $thisarticle and $author globals. The tag itself doesn’t really suit the job in pure PHP.

Offline

#3 2009-08-09 21:17:26

walter976
New Member
Registered: 2009-08-02
Posts: 7

Re: if_author function problem

Thanks Gocom, I just wanted to execute some code if the called page is the result of an article search by ANY author.

I wasn’t smart enough to see that there was a global variable $author to do this, by the way is there a reference list with the descripron of these useful global variables?

Thanks again for helping

Offline

#4 2009-08-09 21:56:52

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: if_author function problem

walter976 wrote:

I wasn’t smart enough to see that there was a global variable $author to do this, by the way is there a reference list with the descripron of these useful global variables?

Not an up-to-date one I’m aware of. But like me, you can always build automatic lists from the source. Most SVN/editor tools do include regex/list/search tools that can be used. For example you could fetch all strings after global which brings you the list of globals.

Also simple tools as PHPXref or Google code can be used to build such lists.

Offline

Board footer

Powered by FluxBB