I have a little problem, which I can’t figure out by myself.
I created sort of a “webengine”, which I build out of several classes.
The main-class, getting a “theme’s” internals is called “Logic”.
This logic-class includes all the files, needed for a website. I made it like that, so that every developer, creating such website could use function, that are given inside this class.
I now want to create a function, that allows these developers to include a CSS file. But this turns out to be quite difficult.
So far I tried this:
public function include_css($path_to_css) { $path_to_css = $this->project_name . THEMES . "/" . ACTIVE_THEME . "/" . $path_to_css; if(file_exists($path_to_css)) { ?> <html> <head> <link rel="stylesheet" type="text/css" href=" <?php echo $path_to_css; ?>" /> </head> <?php } else { return false; } } /* Idea number 2 */ public function include_css($path_to_css) { $path_to_css = $this->project_name . THEMES . "/" . ACTIVE_THEME . "/" . $path_to_css; if(file_exists($path_to_css)) { echo " <html> <head> <link rel='stylesheet' type='text/css' href='".$path_to_css."' /> </head> "; } else { return false; } }
Please note that unclarified attributes are declared in a complex matter, so it would be a very long post, if I would paste these here.
I am just getting this console error: http://127.0.0.1/vpm2/themes/numberOne/css/test.css 404 (Not Found), which means there is no such file. The interesting thing about that, is, that this is the exact path to the right file!
Is there anything I am missing?
Advertisement
Answer
I found the solution. Apparently the CSS Path seems to be wrong. It needs to look like that:
$path_to_css = THEMES . "/" . ACTIVE_THEME . "/" . $path_to_css;
So the result looks like that:
themes/numberOne/test.css
Before it looked like that:
/vpm2/themes/numberOne/test.css