Skip to content

Commit

Permalink
Made Universal Analytics only applicable when the version is less tha…
Browse files Browse the repository at this point in the history
…n 1.9.1 as it is supported in newer versions.
  • Loading branch information
adampmoss committed Jun 4, 2015
1 parent 0bf20b3 commit bfaacaf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ app/etc/config.xml
app/etc/local.xml
app/etc/local.xml.additional
app/etc/local.xml.template
app/locale/en_US/
app/locale/
app/Mage.php
cron.php
cron.sh
Expand Down
31 changes: 21 additions & 10 deletions app/code/community/Creare/CreareSeoCore/Model/Observer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

class Creare_CreareSeoCore_Model_Observer extends Mage_Core_Model_Abstract {

/* Our function to change the META robots tag on Parameter based category pages */

public function changeRobots($observer) {
Expand Down Expand Up @@ -171,6 +172,8 @@ public function saveConfigOnConfigLoad($observer) {
}
}
}*/

/* Checks if the page loaded is the canonical version, if not redirects to that version */

public function forceProductCanonical(Varien_Event_Observer $observer)
{
Expand All @@ -188,24 +191,24 @@ public function forceProductCanonical(Varien_Event_Observer $observer)
}
}
}

/* Adds the page title and meta description to the contact page's <head> */

public function contactsMetaData(Varien_Event_Observer $observer)
{
if ($observer->getEvent()->getAction()->getRequest()->getRouteName() === "contacts")
{
if (Mage::helper('creareseocore/meta')->config('contacts_title'))
{
if ($observer->getEvent()->getAction()->getRequest()->getRouteName() === "contacts") {
if (Mage::helper('creareseocore/meta')->config('contacts_title')) {
$observer->getEvent()->getLayout()->getBlock('head')->setTitle(Mage::helper('creareseocore/meta')->config('contacts_title'));
}

if (Mage::helper('creareseocore/meta')->config('contacts_metadesc'))
{

if (Mage::helper('creareseocore/meta')->config('contacts_metadesc')) {
$observer->getEvent()->getLayout()->getBlock('head')->setDescription(Mage::helper('creareseocore/meta')->config('contacts_metadesc'));
}
}

}


/* If set, replaces the homepage title with the definitive one set in the config */

public function forceHomepageTitle($observer)
{
if (Mage::getStoreConfig('creareseocore/defaultseo/forcehptitle')) {
Expand All @@ -222,6 +225,8 @@ public function forceHomepageTitle($observer)
}
}
}

/* On relevant pages, will override the page title with the fallback if one isn't set in the editor */

public function setTitle($observer)
{
Expand All @@ -239,6 +244,8 @@ public function setTitle($observer)

$layout->generateXml();
}

/* On relevant pages, will override the meta desc with the fallback if one isn't set in the editor */

public function setDescription($observer)
{
Expand Down Expand Up @@ -346,9 +353,13 @@ public function setMandatoryAltTag($observer)
}
}

/* Sets Google Analytics to use UA when the version is less that 1.9.1 and it is set in the config */

public function setUA($observer)
{
if (Mage::getStoreConfig('creareseocore/googleanalytics/type'))
$magentoVersion = Mage::getVersion();

if (Mage::getStoreConfig('creareseocore/googleanalytics/type') && version_compare($magentoVersion, '1.9.1', '<'))
{
$layout = $observer->getEvent()->getLayout();
$layout->getUpdate()->addUpdate('<reference name="after_body_start"><remove name="google_analytics" /><block type="creareseocore/googleanalytics_ua" name="universal_analytics" template="creareseo/googleanalytics/ua.phtml" /></reference>');
Expand Down

0 comments on commit bfaacaf

Please sign in to comment.