xoops forums

kerkyra

Just can't stay away
Posted on: 2009/10/20 11:31
kerkyra
kerkyra (Show more)
Just can't stay away
Posts: 553
Since: 2005/2/14
#1

adding jquery in admin <head>

hi is there a way to add the jquery.js file in the head of admin when loading a module admin section? like the one used in frontend to load scripts from frameworks folder (browse.php).

I would like to load jquery but in the head of the admin html code not just anywhere.

Thanks

kerkyra

Just can't stay away
Posted on: 2009/10/21 9:11
kerkyra
kerkyra (Show more)
Just can't stay away
Posts: 553
Since: 2005/2/14
#2

Re: adding jquery in admin <head>

bump?

trabis

Core Developer
Posted on: 2009/10/21 13:09
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#3

Re: adding jquery in admin <head>

$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');// use browse.php to access xoops_lib folder
$xoTheme->addScript('modules/yourmodule/js/yourscript.js');// you can use full path or path relative to root


Use this after including xoops_cp_header();
and before including xoops_cp_footer();

kerkyra

Just can't stay away
Posted on: 2009/10/22 8:33
kerkyra
kerkyra (Show more)
Just can't stay away
Posts: 553
Since: 2005/2/14
#4

Re: adding jquery in admin <head>

I already tried that mate! i'm using a function to show the admin side. I set $xoTheme as global and then try that line of code that you suggested. all i get is this error!

Fatal error: Call to a member function addScript()

Not sure how to get the instance of $xoTheme. Is it set in admin area? Do i have to initiate it? I'm using XOOPS 2.3.3. Thanks for the help mate.

trabis

Core Developer
Posted on: 2009/10/22 12:50
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#5

Re: adding jquery in admin <head>

You should move this topic to 2.3 support.

There is no way to add scripts into 2.3 admin header, sorry.

hervet

Friend of XOOPS
Posted on: 2009/10/22 12:57
hervet
hervet (Show more)
Friend of XOOPS
Posts: 2267
Since: 2003/11/4
#6

Re: adding jquery in admin <head>

Simply type :
echo "<script type="text/javascript" src="http://www.example.org/myscript.js"></script>";


It does not change anything to call it from the head or from the "bottom".
Yahoo even advice to call JS scripts in the bottom of the pages ...

sailjapan

Moderator
Posted on: 2009/10/23 6:34
sailjapan
sailjapan (Show more)
Moderator
Posts: 1672
Since: 2005/11/16
#7

Re: adding jquery in admin <head>

Quote:
You should move this topic to 2.3 support.


Done

kerkyra

Just can't stay away
Posted on: 2009/10/23 8:26
kerkyra
kerkyra (Show more)
Just can't stay away
Posts: 553
Since: 2005/2/14
#8

Re: adding jquery in admin <head>

actually it was my mistake! the version is 2.4.0 RC in which i'm writing this module.

I guess i should just echo the script for the module to be compatible with 2.3..

but i would also like to know how this could be done in 2.4 and why the $xoTheme didnt work.
Quote:

It does not change anything to call it from the head or from the "bottom".
Yahoo even advice to call JS scripts in the bottom of the pages ...

@hervet : mate i just want the code to be tidy. If i echo the script then it will be echoed somewhere between the body tags and not in the head or the bottom. Thats why i'm asking this. I know its not important, its what i've done so far to make the code work. I was just wondering how this could be done differently.


Thanks for your answers and the help guys. Have a nice one.