Content Management Systems

Joomla! Hack – Fix Category Trailing Slash CSS Error in SH404SEF

This is more of a: you should know this, rather than a Hack. I had a problem where any page that had its URL formatted by SH404SEF with a trainling slash “/” instead of HTML, lost its CSS properties. Turns out if you manually insert a template file such as in Dreamweaver and upload with that format it will think that the “/” represents a new base directory. Solve this by using Joomla’s own base directory command: <link rel=”stylesheet” href=”/baseurl ?>/templates/templatename/css/template.css” type=”text/css” /> or by using .. to denote the base directory. <link rel=”stylesheet” href=”/../templates/templatename/css/template.css” type=”text/css” />. Either way should work.

Read more

Joomla! Hack – Add Query String to Chronforms Redirect URL from POST Value

I had an instance where I needed an ID Variable to be placed in the URL as a query so i could pull it down from the next page with Javascript. I wanted the URL Redirect field not to just go to http://www.example.com/thinking.html but tohttp://www.example.com/thinking.html?xID=(ID Variable) In order do do this we need to edit chronocontact.php in components/com_chronocontact On Line 359 we find: $mainframe->redirect($cf_rows[0]->redirecturl); We concactenate the query string we want and add the POST Variable from the previous form (that i was generating with mktime() ) So we change it to : $mainframe->redirect($cf_rows[0]->redirecturl.”?xID=”.$_POST[‘xID’].””); Hope this helps some of you! Complete Modified Code: if ( !empty($cf_rows[0]->redirecturl) ) { if ( !$debug ) { $mainframe->redirect($cf_rows[0]->redirecturl.”?xID=”.$_POST[‘xID’].””); } else { echo “<div class=’debug’ >Redirect link set, click to test:<br /> <a href=’”.$cf_rows[0]->redirecturl.”‘>”.$cf_rows[0]->redirecturl.”</a></div>”; }

Read more

Joomla! Hack – Using Chrono forms with HTTPS

go to modules/mod_chronocontact/helper.php change all JURI::base() to JURI::base( true ) This will stop Chronocontact from using default http://www.yoursite.com and use the base directory “/” which then allows Joomla to use HTTPS instead of HTTP. Otherwise JURI will create form POST ACTION to JURI which is in HTTP.

Read more

Joomla! Hack – Save Title Alias with Capital / Uppercase letters

How to stop Joomla from Reformatting your Title Alias to Lowercase I found this core hack a while ago but couldn’t find it again. I searched and searched until eventually I went digging through Joomla files to find out where it was. If you are tired of having Joomla overwrite your Title Alias, or Article Alias, then this hack is for you. This is very useful when transferring over sites from different systems which used an alias field as the page title, and was case sensitive. The file you need to edit is: libraries\joomla\filter\filterout.php The line of code you are looking for is $str = trim(strtolower($str)); return $str; change this to $str = trim($str); return $str; Do not remove the block of code all together as doing this will cause Joomla to replace your alias’ with Time Stamps. The following is the full function edited function stringURLSafe($string) { //remove any ‘-‘ from the string they will be used as concatonater $str = str_replace(‘-‘, ‘ ‘, $string); $lang =& JFactory::getLanguage(); $str = $lang->transliterate($str); // remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace(array(‘/\s+/’,’/[^A-Za-z0-9\-]/’), array(‘-‘,”), $str); // lowercase and trim $str = trim($str); return $str;

Read more

Better SEF URL’s for Blogs and News – Joomla! Hack

All credit to this article goes to Ahmad from Alfy Studio. Great work!! sh404SEF is a Joomla! extension helps you creating better SEF URLs. It’s full of features and parameters that helps you to acheieve the format you want for your Joomla! website. On July 24th 2008 the JED editors announced that sh404SEF has been added to the editors’ pick. Development cycle continued and sh404SEF became one of the must have extensions. Bascially an article will have a URL similar to this : “http://localhost/index.php?option=com_content&view=article&id=19” With joomla built-in SEF URLs enabled the URL will be similar to : “http://localhost/category-name/19-article-title” That looks much better and more human readable. Better for SEO too! It’s effective yet very limited! We don’t have much control over the URL format. For example there is no way to hide the article-id prefixed to the title. It doesn’t tell the visitor any useful thing; why to use it? For a lot of things we need extensions to handle SEF URLs. We need more control and more options. When using sh404SEF an article should have a URL similar to this one : “http://localhost/category-name/article-title.html” Similar to Joomla’s built-in URL but better. You can set the parameters to show/hide the section/category, use an extension like .html and more. There is a nice feature in sh404SEF helps adding a unique-id for the URL. When enabled the URL should look similar to : http://localhost/2008081219/category-name/article-title.html” That unique id is created using the date of creation (yyyy-mm-dd) added to the article id. Well that could be of great value with minor modification to modify the output to something better! Take a look at the following : “http://localhost/category-name/2008/08/12/article-title.html” Even better, This URL tells a story! Obviously that’s a date of creation and not just a weird number! To create such a format we need to modify sh404SEF files. To get started : Install sh404SEF. Rename the file in your website root called htaccess.txt to .htaccess From SEO Settings in Joomla’s Global Configuration enable both Search Engine Friendly URLs andUse Apache mod_rewrite Go to sh404SEF control panel, make sure you’re using the extended display by clicking on the blue notice message on the right. Open sh404SEF configuration : on Main set Unique ID to Yes on Plugins set show-section/show-category to what suits you on Advanced set Rewriting mode to with .htaccess ( mod_rewrite ) Save settings. Lets digg into the code. Start by editing the file: /components/com_sh404sef/sef_ext/com_content.php That’s the file responsible for handling the URLs for the contents. Find and delete the following code: 01.// V 1.2.4.j 2007/04/11 : numerical ID, on some categories only 02.if ($sefConfig->shInsertNumericalId && isset($sefConfig->shInsertNumericalIdCatList) 03.&& !empty($id) && ($view == ‘article’)) { 04. 05.    $q = ‘SELECT id, catid, created FROM #__content WHERE id = ‘.$id; 06.    $database->setQuery($q); 07.    if (shTranslateUrl($option, $shLangName)) // V 1.2.4.m 08.    $contentElement = $database->loadObject( ); 09.    else $contentElement = $database->loadObject( false); 10.    if ($contentElement) { 11.        $foundCat = array_search($contentElement->catid, $sefConfig->shInsertNumericalIdCatList); 12.        if (($foundCat !== null && $foundCat !== false) 13.        || ($sefConfig->shInsertNumericalIdCatList[0] == ”))  { // test both in case PHP < 4.2.0 14.            $shTemp = explode(‘ ‘, $contentElement->created); 15.            $title[] = str_replace(‘-‘,”, $shTemp[0]).$contentElement->id; 16.        } 17.    } 18.} Save and close the file. Open: /components/com_sh404sef/sef_ext.php Find this line : 1.if (isset($row->category)) { 2.    $title[] = $row->category; 3.} Insert this code after : 01.// V 1.2.4.j 2007/04/11 : numerical ID, on some categories only 02.if ($sefConfig->shInsertNumericalId && isset($sefConfig->shInsertNumericalIdCatList) 03.&& !empty($id) && ($view == ‘article’)) { 04. 05.    $q = ‘SELECT id, catid, created FROM #__content WHERE id = ‘.$id; 06.    $database->setQuery($q); 07.    if (shTranslateUrl($option, $shLangName)) // V 1.2.4.m 08.    $contentElement = $database->loadObject( ); 09.    else $contentElement = $database->loadObject( false); 10.    if ($contentElement) { 11.        $foundCat = array_search($contentElement->catid, $sefConfig->shInsertNumericalIdCatList); 12.        if (($foundCat !== null && $foundCat !== false) 13.        || ($sefConfig->shInsertNumericalIdCatList[0] == ”))  { // test both in case PHP < 4.2.0 14.            $shTemp = explode(‘ ‘, $contentElement->created); 15.            $title[] = str_replace(‘-‘,’/’, $shTemp[0]).”/”; 16.        } 17.    } 18.} We’ve only modified the last line from the code we removed from the first file. Moved the code to be appeneded after the /section-name/category-name/ in the URL The ( – ) are replaced with ( / ) using str_replace Removed the itemid contentElement->id Added the ( / ) to the end. Save the file and now purge SEF URLs you have from the sh404SEF control panel. Try reloading your website and see how the URLs look now If you’ve better ideas or modifications please share it! Have a nice day!  

Read more