Topic Closed
372 Posts
4 Themes
9 Plugins

I tried to add a local javascript which resides in a /js - subdir of a template, but what i saw in the forum did not function

$page->head_js[] = $addonRelativeCode.'/init.js'; is for plugins  - does not come up

$page->head_js[] = '/js/javascript.js';  gives in the sourcecode a link to '/js/init.js'; and so does not function: just a klick on the link in the sorcecode of firefox....

echo '<script src="'.dirname($page->theme_path).'/js/init.js"></script>'; does not function ! - does not come up in the source of the site

I found a solution  :

global $page,  $themepath;

$themepath = $page->theme_path;

$dirjs = dirname($themepath) ;  // $dirjs = dirname($page->theme_path) ; 

$page->head_js[] = $dirjs . '/js/init.js'; 

and finally

$page->head_js[] = dirname($page->theme_path) . '/js/init.js'; 

But who knows a documented standard solution for Typesetter 5.1

What i found at Github was

$page->head_js[] = rawurldecode($page->theme_path).'/script.js';


Edited: 3 years ago#11040

1.5K Posts
16 Plugins

$page->head_js[] = rawurldecode($page->theme_path).'/script.js';

is the safest route to go because it will even cope with theme folder names containing spaces and/or special characters.

AFAIK, $addonRelativeCode will only be availabe inside plugin hooks, which may be part of themes, but most themes don't implement such.

Once a theme uses plugin hooks, such as the getHead hook, you can add custom js and css via this hook using $addonRelativeCode.
E.g. Theme Cajón uses advanced techniques in this regard and makes use of several plugin hooks.

3 years ago#11041

Topic Closed



elFinder 2.1.50 in Upcoming Release

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Ennetbürgen (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Websi...

Find out more about our Provider Spotlight

Log In