Welcome Guest, Not a member yet? Register   Sign In
Problems loading a style css from another directory
#1

Hello!
Today I load a css dynamically as follows:

PHP Code:
   function addStyle($file '')
 
   {
 
       $ci = &get_instance();
 
       $header_css $ci->config->item('header_css');

 
       if (empty($file) || !$file) {
 
           return;
 
       }

 
       if (is_array($file)) {
 
           foreach ($file as $item) {
 
               $header_css[] = $item;
 
           }

 
           $ci->config->set_item('header_css'$header_css);
 
       } else {
 
           $header_css[] = $file;
 
           $ci->config->set_item('header_css'$header_css);
 
       }
 
   

This works fine, but when I try to load into another directory, the function can not find the style, causing error.
Does anyone know of any way to dynamically load the css being able to be in another directory as well?

Thank you!

Reply
#2

@Skinper,

Where is this code loaded? In the Controller or view?
Reply
#3

(04-02-2019, 11:50 AM)php_rocs Wrote: @Skinper,

Where is this code loaded? In the Controller or view?


This code is in a controller that belongs to a project named fw. I call this method on the controller in the MY project.
But the method looks for the css only in the fw folder, but I wanted it to look in the MY driver folder. In short, I wanted addStyle to look up the file I want in the controller folder that calls it, for example:
If it is called by some controller belonging to fw, it looks in the fw folder.
Now if it's called in MY, it looks in the MY folder.
The first works well, but the second does not. I tried to use Directory Helper but did not succeed.
Thanks !!
Reply
#4

@Skinper,

Have you tried creating a backup directory for the system to look into if it is unable to find it in the primary directory? You could also define it in your view header and send a flag (from the controller) to tell the code where to find the CSS. I'm surprised that you don't keep all the assets (images, css, javascript libraries) in a specific location so that it is consistent across the web application.
Reply
#5

(04-03-2019, 01:51 PM)php_rocs Wrote: @Skinper,

Have you tried creating a backup directory for the system to look into if it is unable to find it in the primary directory?  You could also define it in your view header and send a flag (from the controller) to tell the code where to find the CSS.  I'm surprised that you don't keep all the assets (images, css, javascript libraries) in a specific location so that it is consistent across the web application.

I tried this for a flag, but it still does not recognize the css directory.

Assets are shared by 2 projects, so it works like a firmware for them. I do not think that's the best way, but it's not in my power to change that now, but thanks for the touch.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB