September 10, 2010, 04:44:53 AM *

Login with username, password and session length
News: How to make BJ Image Slider works with other template than BJ Synegy ?
http://byjoomla.com/forum/index.php?topic=16.msg118#new
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to make BJ Image Slider works with other template than BJ Synegy ?  (Read 1247 times)
hadoanngoc
Newbie
*
Posts: 3


Email
« on: January 14, 2010, 11:59:25 AM »

Hi all,
We notice that some of our customers can not get BJ ImageSlider works with other template than BJ Synegy, so we decide to raise the problem here you all of you can know it  Smiley
Let's first talk about Joomla 1.5 javascript libs. It automatically load some js libraries, one of them is mootools, which is used by BJ ImageSlider too. However, the problem is Joomla's mootools version is sometimes older than what BJ ImageSlider needs (usually, Joomla Mootools version is 1.12, while BJ ImageSlider work with 1.2.x).
With BJ Synegy template, it automatically replaces Joomla Mootools version by a newer version which is bundled with the template, therefore, no problem occurs !
So, how to overcome this ?  Roll Eyes
Ofcourse, you need to replace Joomla mootools by yourself. It is located in "\media\system\js" folder with the name "mootools.js". Download the latest version of mootools at : http://mootools.net/ or just open BJ ImageSlider folder to get the right version.
Next, you need to disable one in two lib (one loaded by Joomla, and one loaded by BJ ImageSlider). To do that, you have 2 options:
+ Edit your template: insert this piece of code into your template index.php file
Code:
<?php if(!defined('_MOOTOOLS_LOADED')){
define('_MOOTOOLS_LOADED','mootools_loaded');}
?>
+ Edit BJ ImageSlider: delete the code which loads mootools lib, in mod_bj_imageslider.php file. It looks like this:
Code:
<?php if(!defined('_MOOTOOLS_LOADED')){
define('_MOOTOOLS_LOADED','mootools_loaded');
?>

<script language="javascript" type="text/javascript" src="<?php echo $MODULE_URL;?>/mod_bj_imageslider/js/mootools.js"></script>
<?php }?>

Now, BJ ImageSlider is ready to work with your site without BJ Synegy. Cheesy

Logged
paisani
Newbie
*
Posts: 3


« Reply #1 on: January 14, 2010, 03:31:33 PM »

This works but upgrading the mootools.js broke the menu drop downs on my Joomla admin screen.
Logged
admin
Administrator
Newbie
*****
Posts: 32


Email
« Reply #2 on: January 15, 2010, 01:56:35 AM »

This works but upgrading the mootools.js broke the menu drop downs on my Joomla admin screen.
Yeah, you are right. If you just want to disable default Joomla mootools on Front-end, you can have a look at BJ Synegy index.php file, copy this piece of code to your template:
Code:
// Disable Mootools library as it is very old
$user =& JFactory::getUser();
if ($user->guest) {  // <= Check guest visit
   $headerstuff = $this->getHeadData();

   // mootols are usually found as the very first entry
   reset($headerstuff['scripts']);
   $moo = key($headerstuff['scripts']);
   // kick it
   unset($headerstuff['scripts'][$moo]);
   // restore
   $this->setHeadData($headerstuff);
}
This code will remove any Joomla Js defaul libraries if a guest visit front-site, including Mootools. After that, load your desired libs if neccessary.

Hope this help.  Roll Eyes

Logged
admin
Administrator
Newbie
*****
Posts: 32


Email
« Reply #3 on: February 20, 2010, 09:58:40 AM »

The complete steps to make your template work with BJ ImageSlider:

- Insert the KICK OFF code (updated in synegy_2.5.4, different from the previous post): this will remove default Mootools library code inserted by Joomla 1.5 itself.

  
Code:
// Disable Mootools library as it is very old
   $headerstuff = $this->getHeadData();
   $keys = array_keys($headerstuff['scripts'], 'text/javascript');
   if(strpos($keys[0],'mootools'))
   {
// kich it
unset($headerstuff['scripts'][$keys[0]]);
   }
   else if(strpos($keys[1],'mootools'))
   {
// kick it
unset($headerstuff['scripts'][$keys[1]]);
   }
   // restore
   $this->setHeadData($headerstuff);

- Re-link the latest version of Mootools into your template by insert these codes after <HEAD> tag:
   
Code:
<script type="text/javascript" src="<?php echo _TEMPLATE_URL?>/mootools.js"></script>
<?php if(!defined('_MOOTOOLS_LOADED')){
define('_MOOTOOLS_LOADED','mootools_loaded');}
?>
Note: copy the latest version of mootools.js to your template folder. Download at: http://mootools.net/ (download and rename to mootools.js)

Now your template is ready to work with BJ ImageSlider.
Following is a sample index.php after do those stuff:
Code:
<?php 
/* Joomla Template by byjoomla.com 
 * BJ Synegy for Joomla 1.5 Free Version
 * To download Pro version with more functions, please check http://byjoomla.com
 */

// no direct access
defined'_JEXEC' ) or die( 'Restricted access' );

// Disable Mootools library as it is very old
   
$headerstuff $this->getHeadData();
   
$keys array_keys($headerstuff['scripts'], 'text/javascript'); 
   if(
strpos($keys[0],'mootools'))
   {
// kick it
unset($headerstuff['scripts'][$keys[0]]);
   } 
   else if(
strpos($keys[1],'mootools'))
   {
// kick it
unset($headerstuff['scripts'][$keys[1]]);
   }
   
// restore
   
$this->setHeadData($headerstuff);

define'_TEMPLATE_PATH'JPATH_BASE '/templates/bj_synegy');
define('_TEMPLATE_URL',JURI::base().'templates/bj_synegy');
$iso split'='_ISO );
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language?>" lang="<?php echo $this->language?>" >
<head>
<script type="text/javascript" src="<?php echo _TEMPLATE_URL?>/func/mootools.js"></script>
<?php if(!defined('_MOOTOOLS_LOADED')){
define('_MOOTOOLS_LOADED','mootools_loaded');}
?>

<jdoc:include type="head" />
.........
« Last Edit: February 22, 2010, 10:54:08 PM by admin » Logged
Pages: [1]
  Print  
 
Jump to: