Add JS and CSS to a single page

Hi. On the JOIN page I'd like to transform a drop-down to a select2 js widget. What's the best way to add the required assets (js and css) only to the join.php page? Best would be to add from external CDN, but even downloaded locally to the dolphin server is good.

I've seen the addJs and addCss methods, but how do they behave? Should I place my assets in the base folder or in my template's one? 

thanks

Quote · 13 Oct 2014

What the problem to add extra js and css in join.php file?

 

$GLOBALS['oSysTemplate']->addJs("/somewhere/js/yourfile.js");

or as array

$GLOBALS['oSysTemplate']->addJs(array("/somewhere/js/yourfile.js","/somewhere/js/anotherone.js"));

 

The same syntax for $GLOBALS['oSysTemplate']->addCss() function.

http://boonexpert.com
Quote · 13 Oct 2014

You need to know that the join form items won't have an id to them.  You will have to work off of the name instead.

Here is an example of what I mean:

$("input[name=nameGoesHere]").val();

Geeks, making the world a better place
Quote · 13 Oct 2014

 

$("input[name=nameGoesHere]").val();

 or maybe even more simple:

$("input").select2();

http://boonexpert.com
Quote · 13 Oct 2014

 RE

Hi. On the JOIN page I'd like to transform a drop-down to a select2 js widget. What's the best way to add the required assets (js and css) only to the join.php page? Best would be to add from external CDN, but even downloaded locally to the dolphin server is good.

I've seen the addJs and addCss methods, but how do they behave? Should I place my assets in the base folder or in my template's one? 

thanks

 

I would highly recommend Deano's Head injections module for things like this.

http://www.boonex.com/m/Head_Injections

The module allows you to add content between the head tags of any page.  I use it all the time for this exact reason, and it works very well.  It's great for customizing Dolphin's built in pages, as well as those pages that you create yourself.

 

 

P.S. Modzzz will probably be along any minute now to post a link to his injections module. I have no experience with his, so I cannot advise you on that one.

My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 13 Oct 2014

I have the head injection module but not the page injection.  Unless Modzzz has written a head injection module, his module is for injection into the pages in various locations; the page injection module is for a different purpose than the head injection module.  Of course js does not solely have to be injected in the head tag.

Geeks, making the world a better place
Quote · 13 Oct 2014

True, it depends on if you want to change all selectors or just select ones.

Geeks, making the world a better place
Quote · 13 Oct 2014

 

What the problem to add extra js and css in join.php file?

 

$GLOBALS['oSysTemplate']->addJs("/somewhere/js/yourfile.js");

or as array

$GLOBALS['oSysTemplate']->addJs(array("/somewhere/js/yourfile.js","/somewhere/js/anotherone.js"));

 

The same syntax for $GLOBALS['oSysTemplate']->addCss() function.

 this syntax won't work for CDN hosted libraries, that means sourcing from another website like if I want to include http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js.

Other than that, if I decide to have them on my server, should I place my assets in the base folder or in my template's one?

Quote · 17 Oct 2014

 

 

What the problem to add extra js and css in join.php file?

 

$GLOBALS['oSysTemplate']->addJs("/somewhere/js/yourfile.js");

or as array

$GLOBALS['oSysTemplate']->addJs(array("/somewhere/js/yourfile.js","/somewhere/js/anotherone.js"));

 

The same syntax for $GLOBALS['oSysTemplate']->addCss() function.

 this syntax won't work for CDN hosted libraries, that means sourcing from another website like if I want to include http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js.

Other than that, if I decide to have them on my server, should I place my assets in the base folder or in my template's one?


You would not include that one anyway. Dolphin already has jquery loaded on every page. Loading it a second time or loading a different version will only cause conflicts that will break things.

https://www.deanbassett.com
Quote · 17 Oct 2014

And unless restricted by license, you can always place the libraries locally on your server.

Geeks, making the world a better place
Quote · 17 Oct 2014
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.