PDA

View Full Version : Install Google Analytics to Joomla Modified PHP Template


johnMoss
06-01-2012, 03:57 PM
This site is a Joomla 1.5. Normal access to modify html is to go into extensions, choose the template & simply modify from there. In this case, the site has had some overwrites done to the template and instead of seeing HTML there is a php script. Can anyone have a looksee at this script & possibly derive what file to go to and add code to the head? I'm digging around in the files, and honestly shooting in the dark here. I found some files in the layout directory that looked like possibles, but adding code into the head was inneffective. Here is the php file one sees when accessing the code in the normal manner in the admin panel:
<?php
/*
#------------------------------------------------------------------------
JA Purity II for Joomla 1.5
#------------------------------------------------------------------------
#Copyright (C) 2004-2009 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
#@license - GNU/GPL, http://www.gnu.org/copyleft/gpl.html
#Author: J.O.O.M Solutions Co., Ltd
#Websites: http://www.joomlart.com - http://www.joomlancers.com
#------------------------------------------------------------------------
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
include_once (dirname(__FILE__).DS.'libs'.DS.'ja.template.helpe r.php');
$tmplTools = JATemplateHelper::getInstance($this, array('ui', JA_TOOL_SCREEN, JA_TOOL_MENU, 'main_layout', 'direction'));
//Calculate the width of template
$tmplWidth = '';
$tmplWrapMin = '100%';
switch ($tmplTools->getParam(JA_TOOL_SCREEN)){
case 'auto':
$tmplWidth = '97%';
break;
case 'fluid':
$tmplWidth = intval($tmplTools->getParam('ja_screen-fluid-fix-ja_screen_width'));
$tmplWidth = $tmplWidth ? $tmplWidth.'%' : '90%';
break;
case 'fix':
$tmplWidth = intval($tmplTools->getParam('ja_screen-fluid-fix-ja_screen_width'));
$tmplWrapMin = $tmplWidth ? ($tmplWidth+1).'px' : '771px';
$tmplWidth = $tmplWidth ? $tmplWidth.'px' : '770px';
break;
default:
$tmplWidth = intval($tmplTools->getParam(JA_TOOL_SCREEN));
$tmplWrapMin = $tmplWidth ? ($tmplWidth+1).'px' : '981px';
$tmplWidth = $tmplWidth ? $tmplWidth.'px' : '980px';
break;
}
$tmplTools->setParam ('tmplWidth', $tmplWidth);
$tmplTools->setParam ('tmplWrapMin', $tmplWrapMin);
//Main navigation
$ja_menutype = $tmplTools->getMenuType();
$jamenu = null;
if ($ja_menutype && $ja_menutype != 'none') {
$japarams = new JParameter('');
$japarams->set( 'menutype', $tmplTools->getParam('menutype', 'mainmenu') );
$japarams->set( 'menu_images_align', 'left' );
$japarams->set( 'menupath', $tmplTools->templateurl() .'/ja_menus');
$japarams->set('menu_images', 1); //0: not show image, 1: show image which set in menu item
$japarams->set('menu_background', 1); //0: image, 1: background
$japarams->set('mega-colwidth', 200); //Megamenu only: Default column width
$japarams->set('mega-style', 1); //Megamenu only: Menu style.
$japarams->set('rtl',($tmplTools->getParam('direction')=='rtl' || $tmplTools->direction == 'rtl'));
$jamenu = $tmplTools->loadMenu($japarams, $ja_menutype);
}
//End for main navigation
$layout = $tmplTools->getLayout ();
if ($layout) {
$tmplTools->display ($layout);
}

johnMoss
06-01-2012, 04:09 PM
I guess I should add to see the live page:
www.networkingeventfinders.com/subdomain/ (http://www.networkingeventfinders.com/subdomain/)

johnMoss
06-01-2012, 04:52 PM
I installed code on this layout/default.php page. The active page above would assumedly show the code (I uploaded it). It doesn't...
<?php
/*
#------------------------------------------------------------------------
JA Purity II for Joomla 1.5
#------------------------------------------------------------------------
#Copyright (C) 2004-2009 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
#@license - GNU/GPL, http://www.gnu.org/copyleft/gpl.html
#Author: J.O.O.M Solutions Co., Ltd
#Websites: http://www.joomlart.com - http://www.joomlancers.com
#------------------------------------------------------------------------
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$this->_basewidth = 20;
$positions = array (
'welcomebox' =>'welcomebox',
'left1' =>'left',
'left2' =>'left2',
'left-mass-top' =>'left_top',
'left-mass-bottom' =>'left_bottom',
'right1' =>'right',
'right2' =>'right2',
'right-mass-top' =>'right_top',
'right-mass-bottom' =>'right_bottom',
'content-mass-top' =>'top',
'content-mass-bottom' =>'bottom',
'content-top' =>'adv_top',
'content-bottom' =>'adv_bottom',
'inset1' =>'inset1',
'inset2' =>'inset2'
);
$this->customwidth('right1', 22);
$this->customwidth('left1', 22);
//$this->customwidth('right1', 25); <== override right1 column width to 25%. Must call before call definePosition. Can call many time to override many columns.
$this->definePosition ($positions);
?>
<?php if ($this->isIE() && ($this->getParam('direction')=='rtl' || $this->direction == 'rtl')) { ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php } else { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php } ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>">
<head>
<?php $this->loadBlock('head') ?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32246848-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<?php
$document =& JFactory::getDocument();
if (@$_REQUEST['task'] == 'month.calendar')
{
$document->setTitle("Events Calendar");
}
elseif (@$_REQUEST['task'] == 'icalevent.edit')
{
if(@$_REQUEST['evid'])
$document->setTitle("Edit Event");
else
$document->setTitle("Add Event");
}
?>
<body id="bd" class="fs<?php echo $this->getParam(JA_TOOL_FONT);?> <?php echo $this->browser();?> <?php if($this->getParam(ca_colorVariation)){ echo $this->getParam(ca_colorVariation); } ?>">
<div id="ja-wrapper">
<a name="Top" id="Top"></a>

<!-- HEADER -->
<?php $this->loadBlock('header') ?>
<!-- //HEADER -->

<!-- MAIN NAVIGATION -->
<?php $this->loadBlock('mainnav') ?>
<!-- //MAIN NAVIGATION -->
<?php $this->loadBlock('showcase') ?>
<?php $this->loadBlock('welcome') ?>

<?php $this->loadBlock('topsl') ?>

<jdoc:include type="message" />

<!-- MAIN CONTAINER -->
<div id="ja-container" class="wrap <?php echo $this->getColumnWidth('cls_w'); ?>">
<div class="main clearfix">

<div id="ja-mainbody" style="width:<?php echo $this->getColumnWidth('mw'); ?>%">
<?php $this->loadBlock('user2') ?>
<?php $this->loadBlock('main') ?>
<?php $this->loadBlock('left') ?>
</div>
<?php $this->loadBlock('right') ?>
</div>
</div>
<!-- //MAIN CONTAINER -->

<?php $this->loadBlock('botsl') ?>

<!-- FOOTER -->
<?php $this->loadBlock('footer') ?>
<!-- //FOOTER -->



</div>
<!-- COPYRIGHT BLOCK -->
<?php $this->loadBlock('copyrights') ?>
<!-- //COPYRIGHT BLOCK -->
<jdoc:include type="modules" name="debug" />
<?php if ($this->isIE6()) : ?>
<?php $this->loadBlock('ie6/ie6warning') ?>
<?php endif; ?>
</body>
</html>

edbr
06-02-2012, 02:10 AM
havent looked at joomla for yonks but do they use .tpl files?

johnMoss
06-02-2012, 06:34 AM
havent looked at joomla for yonks but do they use .tpl files?
Yes

I also discovered my site management is flawed in DW. Manana I will try a direct load to the root with the above page. I also put in a request to the team who modified the template in the first place to get the low down... I'll report the answer...

edbr
06-02-2012, 06:44 AM
right , i usually go strait for the tpl files when modifying templates

johnMoss
06-02-2012, 06:47 AM
To do that locally I need a server app on my comp, yes?

edbr
06-02-2012, 06:50 AM
yes thats easy peasy though. i put a few links in the php section i use wamp. also the code lobster link gives you a 30 day joomla plugin but i have never used it so cant coment

edbr
06-02-2012, 06:53 AM
http://www.dreamweaverclub.com/forum/showthread.php?t=42953

johnMoss
06-02-2012, 04:38 PM
Google Analytics resolved:
I did it right the first time, my site definitions are off. Loaded directly via filezilla all check good.

mynamebilalzahid
03-16-2016, 07:43 AM
thanks for sharing this.