Giter Site home page Giter Site logo

Comments (6)

bkader avatar bkader commented on May 9, 2024

Hi.
On the master view page echo js_files wherever you want.

from ci-theme.

Hirlysm831 avatar Hirlysm831 commented on May 9, 2024

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

from ci-theme.

bkader avatar bkader commented on May 9, 2024

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 : '';

from ci-theme.

bkader avatar bkader commented on May 9, 2024

@Hirlysm831 please tell me if it worked for you so I can close this issue.

from ci-theme.

Hirlysm831 avatar Hirlysm831 commented on May 9, 2024

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

from ci-theme.

bkader avatar bkader commented on May 9, 2024

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.

from ci-theme.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.