How to Know Which Files Are Being Included in a Joomla Page?

You’ve probably been there before:

  • You notice something wrong on your Joomla website. (for example, a typo)
  • You’re sure how to fix it.
  • You search the database to see if the problem is there.
  • You don’t find the problem there, so you’re now sure that the problem resides in the filesystem.

A quick way to address this issue is by downloading the files for the whole website, and then search all these files for the problem (using a multi-file search tool). That can be a very tedious process. (Note: This can also be done by connecting to the website using an SSH client and issuing a grep command to find the file(s)).

However, in some situations, doing the above is not practical especially when the number of matching files is very large. So, what to do in this case to find the file(s) that should be changed?

In our opinion, the easiest way to find these files is by “shortlisting” the files in the Joomla filesystem. “How?” – you may ask. The answer is easy, all that needs to be done is to print a list of all the files included by the Joomla page, which can easily be done by the function get_included_files. Here’s what you should do:

  • Open the index.php file of the template that you’re using. This file should be located under /yourjoomlawebsite/templates/yourtemplatename/.
  • Just after the </html> tag, add the following code:

    <?php
    	print_r(get_included_files());
    ?>

Now when you view any page on your website, you will see at the end of the page a list of all the files that were included to execute that page (e.g. all the files that were included using the include[_once] or the require[_once] directives). Of course, the number of listed files can be overwhelming, but this method will definitely help you locate that hidden file that you absolutely need to change.

If you’re trying to change something on your website but you are having some hard times doing it (even after reading the above), then all you need to do is to contact us. We are Joomla experts and we can definitely help you. Our rates are very affordable, we are very friendly, and we always get the job done!

No comments yet.

Leave a comment