Coder Social home page Coder Social logo

Comments (6)

back2arie avatar back2arie commented on July 30, 2024

Hi

You might want to check out latest code. Plugin is now using hook scenario and all plugin is stored on /application/plugins/.
There's some plugin example on the current code that might help you out.

from kalkun.

agsotelo avatar agsotelo commented on July 30, 2024

Thanks back2arie, but already look there and still feeling me a little lost.

Perhaps i don't explain correctly.

What i want to know is in what moment the entity "plugin" from DB Schema being update the field "plugin_status" with the installed plugins.

In my research i found in the file "application/models/plugin_model.php" and i found the function "getPluginStatus($name)". It's suppose this function check out plugin's status, but seem's don't work correctly because there isn't any record in the entity "plugin".

I only want to check if my plugin is loaded correctly to display (or not) some code, that's all.

Thansk in advance!

from kalkun.

agsotelo avatar agsotelo commented on July 30, 2024

I solved my problem, but i don't know if there is the best way, anyway i will try to explain what i done:

  1. Put the code below in the controller to check if the plugin is loaded:
    /////////////////////////////////
    // Inside the constructor put this
    $this->load->model('Plugin_model', 'plugin_model');
    /////////////////////////////////
    .
    .
    .
    /////////////////////////////////
    // Inside the method who called the view put this
            // Check if 'category_company' plugin is active
            // 
            // Only plugins in the database are active ones
            $encontrado = false;

            $plugins = $this->plugin_model->get_plugins();
            if ( $plugins->num_rows() > 0 ) {
                foreach ($plugins->result() as $plugin) {
                    if($plugin->plugin_system_name == 'category_company') {
                        $encontrado = true;
                    }
                }
            }
            // If found then make the dinamyc control
            if($encontrado == true) {
                // Options
                $options = array('0' => 'Select a Company', 
                                 '1' => 'Option 1',
                                 '2' => 'Option 2'
                                );
                // Make select element and pass it throw the $data parameter
                $data['category_company'] = form_dropdown('company', $options, '0');
            }
            // Pass the $data information to the view
    $this->load->view($the_view, $data);
  1. Put the code below in the view to show/hide my select element


And that's all.

To try this only need to go to the item "plugin" from the menu and disable/enable the plugin.

I wonder if there is a better way to do the same without using the "Plugin_model", perhaps using a method in the plugin library ( I tried this using $plugins_active['plugin_system_name'] invoking the library from the constructor without lucky).

Thanks in advance!

from kalkun.

back2arie avatar back2arie commented on July 30, 2024

Hi

"application/models/plugin_model.php" is currently unused due the change of the plugin scenario.

To check whether plugin is already installed or not, you can do this ugly hack.
Add this function on "application/libraries/plugins.php":

function get_installed_plugin()
{
    return Plugins::$plugins_active;
}

And you can easily call it from your plugin.

from kalkun.

back2arie avatar back2arie commented on July 30, 2024

Or, even better:

function check_installed_plugin($name)
{
    $installed_plugin = Plugins::$plugins_active;
    return array_key_exists($name, $installed_plugin);
}

from kalkun.

agsotelo avatar agsotelo commented on July 30, 2024

Thanks back2arie :)

from kalkun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.