Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-12-09 17:54:48

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

PHP Newbie: How do I call an existing function from my Plugin?

I want to call one of the existing functions (such as the Link list) but pass it certain criteria that my plugin determines.


Eric

Offline

#2 2004-12-09 17:58:36

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: PHP Newbie: How do I call an existing function from my Plugin?

The function name is just the name after the txp: business, so there’s the name. You would have to create an $atts hash that has the parameter name the function is expecting as the index and the parameter value the function is expecting as the value of the index in the hash.

It might also be nice to do a check to see if the function exists if you’re relying on another plugin to be installed. I forget what this function’s name is though. You can probably look it up in the PHP manual. It’s my #1 resource for looking up the myriad functions I don’t know.

Regards,
Remillard

PS: Alternatively I just thought of another way to do it. It’s not the nicest way, but it might be a quick and dirty thing to try if you have trouble with the first and can’t get it to work exactly and want to get some of the rest of it all tested out before going back to it. You could create a string with the tag in it and call parse($string). This adds an extra function call in it, so I wouldn’t keep it in there.

Last edited by Remillard (2004-12-09 18:00:30)

Offline

#3 2004-12-09 18:05:50

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

Re: PHP Newbie: How do I call an existing function from my Plugin?

Here’s an example of calling another function from one of my plugins. Actually, its calling one of Remillard’s plugins:
<code>
$thecount = (is_callable( mdn_count )) ? mdn_count(array( “section”=>$asection, “category” =>$catname )) : “”;
</code>

The function that Remillard was referring to is the is_callable function.

To call into a taghandler function that you know exists you can do something like:
<code>
$permlink = formatPermLink($id,$section).$title;
</code>

Offline

#4 2004-12-10 14:08:27

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

Re: PHP Newbie: How do I call an existing function from my Plugin?

Excellent! That is what I was looking for…

Now to work on the plugin again. My PHP skills are growing. :)


Eric

Offline

Board footer

Powered by FluxBB