0

I have a situation in codeigniter. I am declaring all the CSS ($impcss) and JavaScript ($impjs) files in an array and calling them inside a function:

public function index()
    {
        // Load css here
        $impcss = array("style.css","color.css","transitions.css","bootstrap.css","bootstrap-responsive.css","jquery.bxslider.css","owl.carousel.css","parallax.css");
        $data['impcss'] = $impcss;

        //Load js here
        $impjs = array("jquery-1.11.0.min.js","bootstrap.min.js","jquery.bxslider.min.js","owl.carousel.js","modernizr.js","skrollr.min.js","functions.js");
        $data['impjs'] = $impjs;



        $this->load->view('layout/metainfo',$data);
        $this->load->view('layout/header');
        $this->load->view('homeView');
        $this->load->view('layout/footer');
    }

I want to use the same files in many other functions like the index() function so I want to declare them globally and call them in other functions too. Please help me.

Setily
  • 814
  • 1
  • 9
  • 21
hemanth kumar
  • 529
  • 1
  • 6
  • 25
  • you can make your `$data['impjs']` a session variable, something like `$_SESSION['impjs']`...do not forget to have `session_start();` at the top of your page when using sessions – Luthando Ntsekwa Aug 23 '16 at 09:54
  • can't we use CONSTANTS in this case ? Can't we create create CONSTANT array and declare all the required files over there and get it anywhere we want. – Mittul Chauhan Aug 23 '16 at 09:56
  • 1
    A search before asking a question is always a good idea. SO questions are incredibly well indexed in the standard search engines – RiggsFolly Aug 23 '16 at 09:56
  • create a base_controller and place the array there in constructor or public global array and use in each extended class, i want it to show but posting answer closed for this question – AmmyTech Aug 23 '16 at 10:02

0 Answers0