Skip to content


SEO, Page Rank, Hacks and Joomla 1.5 (Update)

This is an update of the SEO, Page Rank, Hacks and Joomla 1.5.

The previous hack works fine, if and only if, the Joomla installation is located on the root directory. But, it fails when it is installed in a directory under the root directory. To solve the problem, regardless of the location of the Joomla installation, the following line on the file head.php under the "libraries/joomla/document/html/renderer" folder

$strHtml .= $tab . '' . htmlspecialchars($document->getTitle()) . '' . $lnEnd;

need to be replaced with the following

// SEO Hack
// create a new instance of the JConfig
$config = new JConfig();
// get the information from the URI
$info = pathinfo ($_SERVER['REQUEST_URI']);
// that the basename is index.php or index.html if using mod_rewrite or just a default
// in which case, the site name will be set to empty string.
if(( $info['basename'] == 'index.php' ) OR ( $info['basename'] == 'index.html' ) OR ( $info['extension'] == '' ) ) $site_name = '';
// or add the site name before the page title
else $site_name = $config->sitename . ' - ';
$strHtml .= $tab . '' . $site_name . htmlspecialchars($document->getTitle()) . '' . $lnEnd;

In the latest Joomla 1.5.9, the head.php was not part of the upgrade. If you use the upgrade package rather than the full package, your SEO hack will not be affected.

It is always a good practice though to create a log of the file you modify to serve as a guide when you upgrade.

Popularity: 2%

Related Posts

Posted in Joomla, PHP, Scripts.

Tagged with , , , .


4 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Mohamed Kamal Aboelmagd says

    I wish it Works !! ;)

  2. Lucent One says

    This does work and works great. Tried it in Joomla 1.5.16 to 1.5.18

    I use SH404SEF for SEO along with Joomla 1.5.18, Then do the above hack in the head.php page as shown and then comment out lines 100 through 113 in your SH404 component located here:
    /components/com_sh404sef/meta_ext/com_content.php
    *comment lines 100-113 as shown below.

    /*default:
    if ($view==’article’ && !empty($layout) && $layout == ‘form’) { // submit new article
    $title[] = $sh_LANG[$shLangIso]['COM_SH404SEF_CREATE_NEW'];
    if (!empty($sectionid)) {
    $q = ‘SELECT id, title FROM #__sections WHERE id = ‘.$sectionid;
    $database->setQuery($q);
    if (shTranslateUrl($option, $shLangName)) // V 1.2.4.m
    $sectionTitle = $database->loadObject( );
    else $sectionTitle = $database->loadObject( false);
    if ($sectionTitle) {
    $title[] = $sectionTitle->title;
    }
    }
    }*/

    Cheers!
    Lucent One

  3. ???? ???? ??? ????? says

    Really, It works great :)
    Many Thanks,
    Mohamed Kamal Aboelmagd
    ???? ???? ??? ?????

Continuing the Discussion

  1. s.pangonilo.com | Ver Pangonilo : Filipino Engineer » SEO, Page Rank, Hacks and Joomla 1.5 linked to this post on March 10, 2009

    [...] This hack has been updated.Related PostsMarch 10, 2009 — SEO, Page Rank, Hacks and Joomla 1.5 (Update)March 9, 2009 — SEO: [...]



Copyright © 2008 - 2012 Ver Pangonilo
The information on this website in may not be reproduced, republished or mirrored on another web page or website without explicit permission from Ver Pangonilo.