Open Hirlysm831 opened 6 years ago
Hi.
On the master view page echo js_files wherever you want.
OKay simple echo js_files in when ever views right? supposed i had a 2 js files being declared in controller, i want the first js file to be header.php while the other one is place in the footer, placing simple echo js_files in the controller will result to duplicate js files both header and footer, how do we supposed to achieve this thanks
Well what you can do is to echo $js_files
on the header, and in your controller do something like this:
$this->theme->set('extra_js', $this->theme->js('file' ...)
$this->theme->set('extra_js', js('file' ...)
Then, in your master view file, echo it or check if it exists before, like so:
echo (isset($extra_js)) ? $extra_js : '';
@Hirlysm831 please tell me if it worked for you so I can close this issue.
Yes, it helps resolve the conflict somehow, thanks, by the way can you do something like this one? https://github.com/terrylinooo/Codeigniter-Simple-Template-Library setting the js/css to be on header and footer, check on the library it has switch case statement, if you dont mind doing it on your free time, im willing to wait XD Appreciate much for prompt response sir :D
I will see what I can do.
Meanwhile, you can simply set a global variable (name it anything you want. i.e: js_in_header) and set it to false. Then in the main view file check if it's set to true or false to display JS tags in header or footer.
This solution is for ALL tags, not individual tags. There are plenty of possible workarounds but I will do some changes on the library as soon as possible.
Hello, good day i'm not used on posting issues in GitHub, bare me with this one thanks
is there a way we could set the .js files to be included on header and footer or its just me who don't know how to use properly the code thanks a lot.