Traveling abroad and tired of Chrome default search engine forced to different country language? Here is the quick tip to make Chrome to search always in your country specific Google search engine.

  1. Open Google Chrome
  2. Go to Settings
  3. Under Search Engines block, click on Manage search engines link
  4. You can see ADD button beside Other Search Engines heading, click on it
  5. Enter name as something like Google US
  6. Now enter the following URL in corresponding box
    Change {google:baseURL} with your country specific Google site name. For example
  7. Make your new search engine as default by clicking on 3-dot icon on right side of your new search engine row.

Your new search engine is ready!

The most common issue faced by many Joomla webmasters is the conflicting script libraries from multiple extensions they install. For example,

  • Joomla by default comes with Bootstrap library. However since it is on a previous version of the library, most developers tend to use latest version from Bootstrap website. The basic point most developer miss is they are going to provide it to the users who may also uses other extensions and templates. So this will result in conflict from multiple extensions.
  • Another one is Joomla comes by default with Mootools library. Though Joomla switched to jQuery long time ago, many scripts of Joomla are still dependent on Mootools. And some template developers are still using Mootools as their library. So when jQuery and Mootools are loaded on the same page, there could be some issues occur results in broken pages.

Getting things done from such developers is most time consuming and painful process. However if you know little bit of Joomla and PHP stuff, you can fix it yourself. See the examples below.

You can fetch all scripts queued in your web page, before rendering to the browser, using the JDocument. Usually you will do all the below stuff in the component's entry file such as components/com_mycomponent/com_mycomponent.php just before/after the controller is executed Or in the main controller file such as components/com_mycomponent/controller.php however it is not necessary. You could do it in any of the component file for example view file.

$document = JFactory::getDocument();
$headData = $document->getHeadData();
$scripts = $headData['scripts'];

So now we have the scripts that are added to the document by all your extensions. We need to reorder some scripts like Mootools and jQuery. Mootools should always be loaded first on the page and then the jQuery. If this is the issue on your page, you can reorder the as following:

// First create a temporary array to hold reordered scripts
$scripts2 = array();

// if the mootools loaded, add it to the top of the temporary array
$scripts2['/media/system/js/mootools-core.js'] = $scripts['/media/system/js/mootools-core.js'];

// unset the Mootools script from the original array

// now add all jQuery libraries after Mootools in the temporary array
$scripts2['/media/jui/js/jquery.min.js'] = $scripts['/media/jui/js/jquery.min.js'];

// unset the jQuery script from original array

// do the same for noConflict script and jQuery Migrate script
$scripts2['/media/jui/js/jquery-noconflict.js'] = $scripts['/media/jui/js/jquery-noconflict.js'];
$scripts2['/media/jui/js/jquery-migrate.min.js'] = $scripts['/media/jui/js/jquery-migrate.min.js'];

// Now we have two separate arrays of all our scripts,
// merge both so that we have Mootools first, jQuery next
// all other scripts follows
$scripts = array_merge($scripts2, $scripts);

// Now we need to set the scripts to the Joomla Document so that they can be rendered to page
$headData['scripts'] = $scripts;

We are done. Hope you enjoyed this tutorial.

Working with dates is always a challenging task specially because of the timezone compatibility. Fortunately Joomla provides good enough APIs to deal with dates. You can simply display a date in user locale/timezone using below code:

JHtml::date($strdate, 'Y-m-d H:i:s');

That's pretty good stuff in just a line of code. Now what happens if I would like to display the date in the following format and I would like to have the format string to be in a language file (obviously as I can translate static string such as "at" below):

September 11 at 8:20pm

Guess you think its pretty easy, just replace the format string.

JHtml::date($strdate, JText::_('COM_MYCOMPONENT_FULL_DATE_FORMAT'));
Language String: COM_MYCOMPONENT_FULL_DATE_FORMAT="F j \a\t g:i a"

Unfortunately that doesn't work. Even through, I have escaped the characters a and t, it will not display t as \t is the escape sequence for a tab. It will display as

September 11 a 8:20pm


So you need to use double slash to escape it properly (\\t).  If you think, this will work, you are wrong again. The catch is JText will by default interpret backslashes and substitute appropriate characters. So the solution to get this work is force JText not to interpret backslashes by passing the third (optional) parameter as false.

JHtml::date($strdate, JText::_('COM_MYCOMPONENT_FULL_DATE_FORMAT', false, false));

Hope this help someone.

Looks weird! but Joomla did it consistently after the same action carried out, i.e. redirecting to a page after saving. Checked everything but could not found any hint. Here is the code.

$this->setRedirect('index.php?option=com_mycomponentname&view=someview&task=list', JText::_('COM_MYCOMPPONENT_SUCCESS'));

Every time this code executes, Joomla logout me from administration and when I login again, I do not have any admin functions available. I have to logout again and login to get full functionality. Strangely similar code works fine with other function. I do not have any clue until I discovered it is the problem with the language string COM_MYCOMPPONENT_SUCCESS.

The issue is the translation of that string contain some strange characters which came because the translation is not saved with utf-8 encoding. Updated the string, voila! it works now :) . Hope it helps someone stumble upon with same issue.

One of the most useful component on Joomla 2.5 is Redirect component. It records all requests which produce 404 error and allow you to specify the correct url. However the component lacks in many areas specially when you want to do redirect of multiple similar urls using regex. etc. And if you are migrating your component code and want to redirect certain urls, this component may not be useful. But since it is code, it can be handled very well using your code itself. Here comes the method that can set permanent redirect without using .htaccess. Use the following code to permanent redirect requests from your component:

$app = JFactory::getApplication();
$app->redirect(url, '', 'message', true);

where url is your Joomla url. If you want to display a message, you can use second parameter for the same.

You can use this method to fully control what you want to display without effecting search engine rankings.