Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x
Author Message
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Sat Mar 21, 2020 4:27 am Reply with quote

Guys,

I am struggling to get JavaScript at the Module level up and running.

I have it at the site level no problem.

I have searched and read these forums extensively but I can not find a working example of taking a JS lib and loading it on a per module basis.

I need to link the JS file....and then run some inline.

Can someone show me or point me to a working example of this?

Thank You for your help!

Dawg

PS....
I am running 2.5 on php 7.3
 
View user's profile Send private message
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1772

PostPosted: Sat Mar 21, 2020 12:44 pm Reply with quote

Which library do you want to use?

_________________
Github: RavenNuke 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6432

PostPosted: Mon Mar 23, 2020 3:20 pm Reply with quote

You can load JS in the header or body using the addJSToHead, addJSToBody functions in an Include includes/addons/head-xxx.php or includes/addons/body-xxx.php file. You could also include a module?s RN_MODULE_HEAD (add module-level CSS and JS to arrays) (though it's been so long I don't remember this latter approach). For more info, check the RN Wiki

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG


Last edited by kguske on Mon Mar 23, 2020 3:38 pm; edited 1 time in total 
View user's profile Send private message
kguske







PostPosted: Mon Mar 23, 2020 3:33 pm Reply with quote

So, I found this in header.php:
Code:
   // Post 138905 Step 8 - RN_MODULE_HEAD should contain the file to include, with a path relative to the module folder

   if (defined('RN_MODULE_HEAD')) include_once NUKE_MODULES_DIR . $name . '/' . RN_MODULE_HEAD;


And you can find a detailed discussion on it, including a link to download sample code, here.
 
Dawg







PostPosted: Tue Mar 24, 2020 3:01 am Reply with quote

neralex,

Various things in various places. It was just a problem I kept hitting.

This particular post was brought up by wanting a js date picker.

Kguske,

That was what I was looking for...a working example.

Thank You both for all you do!

There are some of us that still work it!

Dawg
 
neralex







PostPosted: Tue Mar 24, 2020 2:32 pm Reply with quote

For single module-files or single module-functions you can use this before the include of the header.php:

php Code:
$datetimepicker = 'path/to/datetimepicker-lib.js';

addJSToHead($datetimepicker,'file'); # file-based

$datepicker_locale = 'en-gb';

$datepicker = '<script type="text/javascript">' . PHP_EOL
. '$(function() {' . PHP_EOL
. ' $( "#datepicker" ).datetimepicker({' . PHP_EOL
. ' format: "E-DD-MM-YYYY",' . PHP_EOL
. ' inline: true,' . PHP_EOL
. ' locale: "' . $datepicker_locale . '",' . PHP_EOL
. ' keepOpen: true,' . PHP_EOL
. ' });' . PHP_EOL
. '});' . PHP_EOL
. '</script>' . PHP_EOL;
addJSToHead($datepicker,'inline'); # load inline-code into head

// addJSToBody($datepicker,'inline'); # load inline-code into body

include_once 'header.php';
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©