Menu

#373 Use a file to set order of script and css loading in theme

XOOPS_2.6
open
MusS
Core (214)
5
2012-09-25
2012-04-16
No

From XavierS:
http://xoops.org/modules/newbb/viewtopic.php?post_id=344695#forumpost344695

could you send this very small hack to the core team
to correct a lot of pb about order script and css loading in theme
( i think, it's also an open way for switching to a mobile theme)
Quote:

/class/theme.php

function xoInit($options = array()){
.....
$GLOBALS['xoopsTpl'] =& $this->template;
//to control order of loading JS and CSS
if (file_exists($this->path ."/theme_onload.php"))
include_once($this->path ."/theme_onload.php");


/themes/(thetheme)/theme_onload.php

<?
global $xoTheme;

$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/ui/jquery.ui.core.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/ui/jquery.ui.draggable.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/ui/jquery.ui.resizable.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.metadata.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/styleswitch.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.hoverIntent.js');
$xoTheme->addScript('browse.php?Frameworks/jquery/mbTooltip.js');
$xoTheme->addStyleSheet('xoops.css');
$xoTheme->addStyleSheet('css/smoothness/jquery-ui-1.8.5.custom.css');
$xoTheme->addStyleSheet('css/style.css');
$xoTheme->addScript('browse.php?Frameworks/jquery/mbMenu.js');
$xoTheme->addStyleSheet('css/menu_style.css');

// by the way we can charge some script only for 1 module
if ($GLOBALS['xoopsModule']->getVar('dirname')=="newbb"){
$xoTheme->addScript('browse.php?Frameworks/jquery/mbContainer.js');
$xoTheme->addStyleSheet('css/menu_red.css');
$xoTheme->addStyleSheet('css/mbContainer.css');
}
?>

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.