5

I've got a custom plugin that I'm using to do some PHP work for a project.

I'm looking for a way to run some of the category methods in the Admin_content class. Are add-ons able to use this class? If so, how?

Basically, I want to run the re-order categories (alphabetically) functionality outside of the CP, inside my add-on.

1
  • Did the answer help you? If yes, please mark correct by clicking on the checkmark to the left of the answer.
    – Anna_MediaGirl
    Commented Dec 22, 2012 at 6:23

1 Answer 1

7

Admin_content extends the CI_Controller class, which is not designed to be instantiated like models and libraries within the MVC paradigm. You can however reuse the libraries within that controller. Unfortunately, the best method here may be to copy and paste your code into your own add-on do what you need. Obviously only copying the bare minimum amount of code needed. And of course, if you can do it without copying, that's always best.

You really have 3 options, none of which do entirely what you want. But this is at least something to get you in the right direction.

  1. Use the Category Model

    $this->EE->load->model('category_model');

  2. Use the Category API

    $this->EE->load->library('api');
    $this->EE->api->instantiate('channel_categories');
    
    $category_tree = $this->EE->api_channel_categories->category_tree($cat_group = 1);
    
  3. Use Channel Data

    https://github.com/objectivehtml/Channel-Data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.