Follow this Blog!

Apr 26, 2012

f Comment

Joomla Find Where Things Are In MINUTES!

First take a look at my Joomla version
Amazon The following is information shown by going to Site -> System Information.

PHP Built OnLinux ip-10-1-2-3 4.5.6-7-ec2 #18-Ubuntu SMP Mon Oct 18 21:00:20 UTC 2010 i686
Database Version5.1.61-0ubuntu0.10.04.1
Database Collationutf8_general_ci
PHP Version5.3.2-1ubuntu4.14
Web ServerApache/2.2.14 (Ubuntu)
WebServer to PHP Interfaceapache2handler
Joomla! VersionJoomla! 2.5.4 Stable [ Ember ] 2-April-2012 14:00 GMT
Joomla! Platform VersionJoomla Platform 11.4.0 Stable [ Brian Kernighan ] 03-Jan-2012 00:00 GMT
User AgentMozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19

As you can see I use Joomla 2.5.4, but this tutorial applies to every previous version of Joomla. If not let me know!

The Problem
If you are new to Joomla you may not know the best way to find things In Joomla code. Whenever you use a module or component or template everything you see in the front-end is actually changeable. You just need to know where they are!

Let me give you an example. If you link a menu item to menu item type called 'Users Manager >> Login Form' then how do I disable the following links on the front-end? How do I remove the following texts in the login page?

*Forgot your password?
*Forgot your username?
*Don't have an account?

Read on to find the BEST way to find where things are in Joomla.

Method #1
Finding where things are in Joomla is actually quite easy. You just need to do a global search in the code base for the text that you are interested in.

So simply issue this command at Joomla's root folder:

sudo grep -R "Forgot your password" *
You should see the following results if you are using the same Joomla version as mine:

language/en-GB/en-GB.mod_login.ini:MOD_LOGIN_FORGOT_YOUR_PASSWORD="Forgot your password?"
language/en-GB/en-GB.com_users.ini:COM_USERS_LOGIN_RESET="Forgot your password?"

Now you know that this text is assigned to two variables: MOD_LOGIN_FORGOT_YOUR_PASSWORD and COM_USERS_LOGIN_RESET. Do another search for them gives you the following results:

ubuntu@ip-10:~/repository/companysitedemo$ sudo grep -R "COM_USERS_LOGIN_RESET" *
components/com_users/views/login/tmpl/default_login.php: <?php echo JText::_('COM_USERS_LOGIN_RESET'); ?></a>
language/en-GB/en-GB.com_users.ini:COM_USERS_LOGIN_RESET="Forgot your password?"
ubuntu@ip-10:~/repository/companysitedemo$ sudo grep -R "MOD_LOGIN_FORGOT_YOUR_PASSWORD" *
language/en-GB/en-GB.mod_login.ini:MOD_LOGIN_FORGOT_YOUR_PASSWORD="Forgot your password?"
modules/mod_login/tmpl/default.php: <?php echo JText::_('MOD_LOGIN_FORGOT_YOUR_PASSWORD'); ?></a>
templates/atomic/html/mod_login/default.php: <?php echo JText::_('MOD_LOGIN_FORGOT_YOUR_PASSWORD'); ?></a>

Now you can go into each file shown here and make changes to the values of these variables and refresh your browser to find out exactly which file is responsible for rendering the links in question. If you are an advanced user of Joomla you'd know by looking at the path which file is the correct one.

This is a general method and should work with articles, modules, components, templates, ... everything!

Method #2
Here is a method to find where things are in Joomla's menu items.

Look at 'Link' field in the menu item's editing page. The field's value is index.php?option=com_users&view=login, which translates to components/com_users/views/login/.

It is up to the component which PHP file to put this frontend code in, but a sensible component developer would put it in a reasonable place. In this case the answer is the following:

The file name makes sense because what you are looking for appears on the login page.

Now log in and you should see a logout button. This page's frontend code is located in components/com_users/views/login/tmpl/default_logout.php. The name of the file gives you a hint as to where things are.

This method works with menu items!

Any questions? Let me know!

Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Google or Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael