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

Use method from plugin in custom module (Markdown)

Development and Programming

Elliot Lewis's avatar
Elliot Lewis
49 posts
13 years ago
Elliot Lewis's avatar Elliot Lewis

I’ve developed quite a few little plugins and some extension hooks but generally I try yo use EEs built in functionality.

But I’ve embarked on something that templates can’t handle and I’m building a fairly complex module and using many of EEs built in classes. It’s been quite fun 😊

I have a requirement where I need to use text data that’s stored as Markdown. I’ve got a plugin to handle this in templates. In my module I don’t want to run the text through the template parse just to invoke the plugin, it would be much more efficient just to run the Markdown code.

As the code is already there how do I use this plugin’s functionality in my Module? Basically how do I access it’s methods?

I’m sue this is a noob question but I’m not sure how to access other plugin, module or extension classes from my code.

Thanks

       
the3mus1can's avatar
the3mus1can
426 posts
13 years ago
the3mus1can's avatar the3mus1can

Take a look in the EE source code at these methods:

$this->EE->load->add_package_path($package_path, FALSE);
$this->EE->load->remove_package_path($package_path);
       
Elliot Lewis's avatar
Elliot Lewis
49 posts
13 years ago
Elliot Lewis's avatar Elliot Lewis

Are you pointing me in the direction of the paths to the model paths? So create a new instance of $CI and load in the correct plugin to my module? Sorry, I’m not really understanding what to do. Any code examples would be great.

       
the3mus1can's avatar
the3mus1can
426 posts
13 years ago
the3mus1can's avatar the3mus1can

In EE 2.4 take a look at the system/expressionengine/libraries/Template.php starting at line 1212. This is how EE handles changing the load paths when it comes across custom plugins and modules in the templates so that those addons will have access to their models, views, etc. when their code gets executed. You can do the same thing in your own addon to temporarily change the load paths so you can access other addons models, views, etc.

       
Bhashkar Yadav's avatar
Bhashkar Yadav
727 posts
13 years ago
Bhashkar Yadav's avatar Bhashkar Yadav

hmmm …. you can use that plugin functionality by including it like including other libraries etc …. as

include_once(PATH_THIRD.'[plugin_directory]/[plugin_file_name]');

and instantiating that plugin class.

       
Elliot Lewis's avatar
Elliot Lewis
49 posts
13 years ago
Elliot Lewis's avatar Elliot Lewis

Thanks Bhashkar. That seems the simplest way of doing it.

I’ve just included the whole plugin code (ie include_once), created a new instance and I’m away using the objects methods. I guess there’s no ‘official’ way of doing this.

So far there’s been no problems and it’s working 😊

       

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.