How to load js/css file in external_form

Permalink
Hello,

I'm making my original form by using external_form blocks.


I need to include js/css files ( put in /var/www/mysite/public_html/concrete5/concrete/blocks/external_form/forms/controllers ).

But I couldn't find the way to include these my js/css files into page's html head.

How can I do that?

Please tell me...


Sorry for my poor English...

Thank you

tetsuya

 
AcruxFarmer replied on at Permalink Reply
AcruxFarmer
Try tracking the header file down here
concrete5/concrete/themes/default/elements/header.php

That is if you are using the default theme. If you have loaded a custom theme go here


concrete5/themes/"yourTheme"/elements/header.php

Good luck
ScottC replied on at Permalink Reply
ScottC
add the js in the elements/header.php in your theme.

If this is some bloated javascript, I would probably write a new controller for that block that does addHeaderItem('js script src here');

That way it isn't being loaded when the visitor first hits the page without having to do some sort of "if" statement to see if the url is index.php with no querystring appended.
zurcxer replied on at Permalink Reply
zurcxer
1. Add your javascript/css file on your blocks/external_form/forms
eg. 
         blocks/external_form/forms/js/contact_form.js


2. Create a constructor on your form cotroller and add the following lines.
public function __construct($obj = null) {
            parent::__construct($obj);
            $html = Loader::helper('html');
            // add advanced tooltips to every page
            $v = View::getInstance();
            $v->addHeaderItem($html->javascript(BASE_URL. '/blocks/external_form/forms/js/contact_form.js'));
        }


3. View source on your web browser. You can see that contact_form.js is added.