1
kerkyra
adding jquery in admin <head>
  • 2009/10/20 11:31

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


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

2
kerkyra
Re: adding jquery in admin <head>
  • 2009/10/21 9:11

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


bump?

3
trabis
Re: adding jquery in admin <head>
  • 2009/10/21 13:09

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


$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();

4
kerkyra
Re: adding jquery in admin <head>
  • 2009/10/22 8:33

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


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.

5
trabis
Re: adding jquery in admin <head>
  • 2009/10/22 12:50

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You should move this topic to 2.3 support.

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

6
hervet
Re: adding jquery in admin <head>
  • 2009/10/22 12:57

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Simply type :
echo "text/javascript" src="http://www.example.org/myscript.js">";
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 ...

7
sailjapan
Re: adding jquery in admin <head>

Quote:
You should move this topic to 2.3 support.


Done

8
kerkyra
Re: adding jquery in admin <head>
  • 2009/10/23 8:26

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


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.

Login

Who's Online

336 user(s) are online (243 user(s) are browsing Support Forums)


Members: 0


Guests: 336


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits