• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[MagicResources] Autoload specific.js & .css files

#1
This is a library who include all javascript and css necesary files. Avoid include unnecesary resources in every pages and load automatically resources based on a config file.

Oficial Helpers autoloaded: Url

How to use:

  1. Configure the application/config/resources.php config file
    PHP Code:
    //Resources applied to all methods of controller
    $config['resources_class'] = array("WELCOME","CONTROLLER1","CONTROLLER2");

    //List of resources of every controller's methods
    $config['resources'] = array(    "welcome.index"         => array("PARTICLES"),    "controller1.index"     => array("FONTAWESOME"),);

    //Resources loaded of every pages
    $config['resources_default'] = array("BOOTSTRAP","JQUERY""ANALYTICS"); 

  2. Define resources in application/config/Magicresources.php -> set_resource method:
    PHP Code:
    case "RESOURCE"//Name of the resource
    return  array("css" =>  array("paths/to/css/files"),"js" =>   array("paths/to/js/files"));
    break; 

  3. Load library
    PHP Code:
    $this->load->library('magicresources'); 

  4. In the view, call Magic Resources's render method
    PHP Code:
    $this->magicresources->render_resources('css'); 

Link to library: https://github.com/50l3r/CI-MagicResources
Reply

#2
Nice done, thx for sharing!

Reply

#3
it's time to share with the community Wink
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.