We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Developing Extensions - How can i call a function in the php file of the extension

Development and Programming

Diario El Mostrador's avatar
Diario El Mostrador
73 posts
16 years ago
Diario El Mostrador's avatar Diario El Mostrador

I’m developing an extension wich revamps the publish form, adding a custom field wich allows to select an image from a gallery(using the gallery module). I want to implement the selection of the especific picture with AJAX… Is there a way to call with an URL a function in the php file of the extension? or something like that? (I want to implement all the backend in the same file)

Thanks (If I manage to finish this extension I will share it 😉 )

       
Greg Aker's avatar
Greg Aker
6,022 posts
16 years ago
Greg Aker's avatar Greg Aker

Depending on what you’re doing, I think you will probably need to include it like you would the typography class.

if ( ! class_exists('Typography'))
{
    require PATH_CORE.'core.typography'.EXT;
}

$TYPE = new Typography;

I’m going to shift this down to the extensions forums, as it’s a better fit.

I hope I’m understanding your question correctly and that is what you’re looking for.

-greg

       
Diario El Mostrador's avatar
Diario El Mostrador
73 posts
16 years ago
Diario El Mostrador's avatar Diario El Mostrador

mmmm, I want to do this :

I have an extension

Class extension
{

 constructor
 .
 .
 .

 function do_something($params)
 {
   //this function is called by a hook etc...
 }

 function do_something_outside_the_extension()
 {
   //do something with $_GET params
 }

}

and i want to somehow externally call function do_something_outside_the_extension

       
Diario El Mostrador's avatar
Diario El Mostrador
73 posts
16 years ago
Diario El Mostrador's avatar Diario El Mostrador

by externally I mean … accesing the logic in do_something_outside_the_extension function by the means of an URL or something

like www.eeserver.com/index.php?do_something_outside_the_extension_function_execution_parameter

       
EliVZ's avatar
EliVZ
37 posts
16 years ago
EliVZ's avatar EliVZ

BUMP! Has anybody figured out how to do this? Or does it HAVE to be a module to call functions?

       
EliVZ's avatar
EliVZ
37 posts
16 years ago
EliVZ's avatar EliVZ

Awesome! Thanks! I will try this out today.

       
caycifish's avatar
caycifish
12 posts
15 years ago
caycifish's avatar caycifish

Did this question get answered? I also want to call a function in my extention (via an AJAX call) from a page in the Forums module, so the solution here might help me.

       
EliVZ's avatar
EliVZ
37 posts
15 years ago
EliVZ's avatar EliVZ

It DID get answered. I think it must have been by Victor G, and was deleted when he got in trouble. Anyway, as I remember the trick is to intercept the page request (using the view_entry_start or admin_home_page_start hooks, depending on whether you’re on the front-end or back-end) and check for your parameter.

In other words, you would call http://example.com/?my_extension=1&my_data=123. Then in your function that is called by the hook, do something like:

global $IN;

if ( !$IN->GBL('my_extension', 'GET') ) 
{
    return;  // This call isn't for us
}
else
{
    // Do your thing here

    $EXT->end_script = TRUE;  // Cancel everything else
}

(Coded off the top of my head. May not work right….)

       
caycifish's avatar
caycifish
12 posts
15 years ago
caycifish's avatar caycifish

Awesome! I’m going to try that this week.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.