How Would I Dynamically Queue Up Javascript Within Page Template?

Permalink
Hi all,

Please excuse me if I get any terminology wrong - this is my first attempt at developing for Concrete5.

I have several different page type templates to create for my Concrete5 theme. They each have the same header and footer but will contain different javascript. Is it possible to do something like Wordpress' wp_enqueue_script function within my page type definition files so that I can simply inject the script tags needed by my template files into my standard header or footer?

I have tried including
$this->addFooterItem(Loader::helper('html')->javascript('js/my_file.js'));


in my page type template but the file path to the script is incorrect - indicating that the function is looking in the root of Concrete5, not in my theme folder.

I have found some guidance online about dynamically including javascript from packages and blocks but not from themes. Is this possible?

 
Ambulare replied on at Permalink Reply
Hmmmm, I may have found the solution.

If you write in the full filepath starting from the root "\" then it will echo out the correct filepath. I guess this can be used to dynamically enqueue scripts, Wordpress-style, then.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Have you tried this
<script type="text/javascript" src="<?=$view->getThemePath()?>/js/my_file.js"></script>