Get Blogged by JoKi

"The only frontiers are in your mind"
28 | 05 | 2017
Navigation
Syndication
Latest Tweets

Most Read Articles
Article Time Line
About me
Family guy, geek, entrepreneur, software craftsman: Visual FoxPro, C#, SQL Server, MySQL, Linux consultant, conference speaker

Certificates & Awards

Microsoft Certified Professional

Microsoft Specialist - Programming in HTML5 with JavaScript and CSS3 Specialist

Get in touch

Sharing is caring

Recent books


Sponsoring
If you like the information on these pages, your support is highly appreciated.
Thank you very much!
Affiliates

 

Spacer for layout formatting

Modified HP Router

User Rating:★★★★★ / 3
PoorBest 
Development 30 January 2010 - 

While looking for some improvements of Joomla! native SEF engine I found the following extension quite interesting and easy to use: HP Router of Hannes Papenberg. Installation is straight forward and no struggles at all. For best results you might install this extension before starting any kind of search engine optimization for your website.

But after a short time I was confronted with some 'nasty' behaviour in my website that was introduced by this extension. Some articles did not show up properly and ended in an HTTP 404 error message. Well, actually reading the description of HP Router gave me an idea of the problem:

ATTENTION!! There are a few things you have to keep in mind with this plugin:
1. You can't have the same alias for two articles, even though they are in different categories. To be precise, you can't have the same alias for any type of content item. As a rule of thumb: If you can get to the list of this type of content items from the administrator menu, you can't use the same alias on two items in that list.

My 404 problem is directly caused by duplicated aliases... but not the obvious way!

The reason here is that the extension (as of writing this article) does not respect the state of the articles in the Joomla! CMS. And due to migration processing from previous blog databases I had a bunch of duplicated topics but deleted. This refers to state -2 instead of published content that has a state of 1.

To correct this problem it is necessary to modify two PHP files of the original HP Router:

  • hprouter/com_contentrouter.php
  • hprouter/com_contactrouter.php

Almost of the end of each file there are the SQL statements to query the database. After you made a backup of your two files you should change them like so:

[code]$db =& JFactory::getDBO();
if($vars['view'] == 'article')
{
$query = 'SELECT id FROM #__content WHERE state = 1 AND alias = '.$db->Quote($vars['id']);
} elseif($vars['view'] == 'category') {[/code]

Modified version of hprouter/com_contentrouter.php

[code]$db =& JFactory::getDBO();
$query = 'SELECT id FROM #__contact_details WHERE state = 1 AND alias = '.$db->Quote($vars['id']);[/code]

Modified version of hprouter/com_contactrouter.php

With those modifications the HP Router works as expected and queries only published articles. Currently, I am not using the archive state of articles but in case that you will, just extend those two queries to include the necessary state values.


blog comments powered by Disqus
 
Spacer for layout formatting