How to add custom template variables?

Discussion forum for MOD Writers regarding MOD Development.
Locked
energyuser
Registered User
Posts: 68
Joined: Fri May 03, 2013 4:56 pm

How to add custom template variables?

Post by energyuser »

When browsing index.php's source code I noticed some inline script tags. I want to have my JS/CSS code separated from the HTML template and I thought I could add them via an external script tag. But instead of writing the whole path to my ./styles/prosilver/scripts/filename.js, I'd like to use something like this: <script type="text/javascript" src="{T_SCRIPTS_PATH}/filename.js"></script>. I know that these global template vars are assigned in the ./includes/functions.php file, but I have no idea how to declare variable T_SCRIPTS_PATH... Any suggestions? All the help I get from here is appreciated and also thanks in advance! :D
Last edited by energyuser on Sat Apr 19, 2014 7:33 pm, edited 1 time in total.
User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: How to add custom template variables?

Post by John P »

Add to the global template variable

Code: Select all

'T_SCRIPTS_PATH'   => $phpbb_root_path . 'path_to_scripts/',
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign
energyuser
Registered User
Posts: 68
Joined: Fri May 03, 2013 4:56 pm

Re: How to add custom template variables?

Post by energyuser »

So, the solution I've found is:

Code: Select all

'T_SCRIPTS_PATH'   => $phpbb_root_path . 'styles/' . rawurlencode($user->theme['template_path']) . '/scripts',
It outputs the following:
./styles/prosilver/scripts/main.js
Now, I only need to know does the script execute correctly.
Locked

Return to “[3.0.x] MOD Writers Discussion”