Topics

User Functions

Events

There are no upcoming events

What's New

Stories

1 new Stories in the last 2 weeks

Comments last 2 weeks


Trackbacks last 2 weeks

No new trackback comments

Links last 2 weeks

No recent new links

NEW FILES last 14 days

No new files

Welcome to Geeklog Saturday, May 25 2013 @ 07:55 PM EDT


 Forum Index > Support > Plugin Support New Topic Post Reply
 SCRIPTS class
   
Al262
 11/11/11 03:44PM (Read 455 times)  
++---
Junior

Status: offline


Registered: 10/19/10
Posts: 16
I am trying to set both a CSS file and include JS file in my plugin. Since it is a plugin, I opened up my functions.inc and added the $_SCRIPT->sets... When I view source after the page is displayed, I do not see a reference to either.

Guidance?

PHP Formatted Code

/**
* Return <head> items for this plugin
*
* @return  html for <link>, <script>, <style>...
*
*/

function plugin_getheadercode_myplug()
{
    global $_SCRIPTS;
    $headerText  = "\n<!-- Javascript and CSS includes -->\n";
    $_SCRIPTS->setCSSFile('myplug', '/myplug/jquery-lightbox-0.5.css', false);
    $_SCRIPTS->setJavaScriptFile('myplug', '/myplug/jquery-lightbox-0.5.js');
    return $headerText;
}
 


 
Profile Email Website
 Quote
Laugh
 11/12/11 03:51PM  
AAAAA
Admin

Status: offline


Registered: 09/27/05
Posts: 878
Your code should work though it looks like your lightbox requires jQuery so you should make sure it is loaded as well by adding

PHP Formatted Code

        $_SCRIPTS->setJavaScriptLibrary('jquery');
 


to tell Geeklog to include it if not already added by some other process. Also setJavaScriptFile by default will add the javascript to the footer not the header.

Tom

 
Profile Email Website
 Quote
::Ben
 11/13/11 05:59AM  
+++++
Full Member

Status: offline


Registered: 01/14/05
Posts: 1359
As sample, you can also look at the code of the jquery plugin or maps plugin.

Ben

We speak french on http://geeklog.fr
 
Profile Email Website
 Quote
Al262
 11/13/11 10:27PM  
++---
Junior

Status: offline


Registered: 10/19/10
Posts: 16
Thanks for the guidance. I added the $_SCRIPTS->setJavaScriptLibrary('jquery'Wink; to the function.inc and the code below to my index.php. All appears to be in order.
PHP Formatted Code

// MAIN
    global $_SCRIPTS;
    $_SCRIPTS->setCSSFile('storygallery', '/storygallery/style.css', false);
    $_SCRIPTS->setJavaScriptFile('storygallery', '/storygallery/jquery.tablesorter.min.js');
        $js  = "\n" . '$(document).ready(function()' . "\n";
        $js .= '{' . "\n";
        $js .= '    $("#storygallery").tablesorter( {sortList: [[0,0], [1,0]]} );' . "\n";
        $js .= '}' . "\n";
        $js .= ');' . "\n";
    $_SCRIPTS->setJavaScript($js, true);
       
$display .= COM_siteHeader('menu', $LANG_STORYGALLERY_1['plugin_name']);
 

 
Profile Email Website
 Quote
Content generated in: 1.26 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to post 
Filtered HTML Allowed 
Censored Content