Hey guys and gals,
I know I could probably be posting this on the Joomla forums but I have come here instead to get a clear explanation from this community because it has always delivered great results in the past. My curiousity on how Joomla's index.php works is getting the best of me lately. For those of you not maybe familar with how the Joomla file structure works everything is launched off a root index.php file and using various includes and require's they have linked together all the elements which deliver the CMS system itself. I quite like this approach because it does keep your root directory looking quite clean. I have spent hours going through the code and trying to figure out how it works with slow progress. What is bugging me is how without switching off of the root index.php it (Joomla) is able to deliver multiple template files and different content for every page. One would think that the basic idea is that you build your template files, every link you click on calls on the template dedicated to that main page/article/post/etc and reloads the main index file thus providing you the appropriate template - I know thats a very basic explanation but I am wondering if anyone familar with this application can elaborate further on how this actually works? Thank you.

Dani AI

Generated

Quick clarification tying and together: the root index.php in Joomla is simply the single entry point that bootstraps the framework, routes the request, and dispatches the correct component/controller. The actual HTML layout comes from the active template (templates/<template>/index.php). Templates use Joomla's document placeholders (the "Joomla tags" mentioned) to inject the component output and modules into the page, which is why the site can show different content and looks without ever replacing the root index.php.

A minimal template layout typically looks like this:

<!DOCTYPE html>
<html>
  <head>
    <jdoc:include type="head" />
  </head>
  <body>
    <jdoc:include type="modules" name="top" style="xhtml" />
    <jdoc:include type="component" />
    <jdoc:include type="modules" name="footer" />
  </body>
</html>

Practical notes: menu assignments and "template styles" determine which template (or template parameters) Joomla loads for a given page; modules are shown/hidden per menu item; component output is produced by components/<component>/views/<view>/tmpl and then injected into the template via <jdoc:include type="component" />. To change output, use template overrides (templates/<your>/html/<component>/<view>/default.php) or module assignment—do not edit core files. For troubleshooting, enable error reporting/debug in Global Configuration, inspect the active template's index.php, and open the component view files to see where the content originates.

Recommended Answers

All 2 Replies

Member Avatar for Member #949455

I have spent hours going through the code and trying to figure out how it works with slow progress.

Joomla has it's own tags for index.php file.

If you are gonna to design the template you need to link index.php file.

The question you are asking is not really a question about php code in Joomla.

It's more like how to insert the files in the CMS.

Think of Joomla tags in the index file as Smarty tags or RainTPL tags.

If you understand how it work and know how to design it.

Then this is very simple to understand with Joomla tags in the index file

I think it's got to do with the fact that Joomla is written following the MVC pattern. All the processing and database access is done somewhere behind (model / controller) and the result is displayed thorugh single index.php page (affected also by a template). On their site they say: Joomla! is always accessed through a single point of entry: index.php (see http://docs.joomla.org/Developing_a_Model-View-Controller_Component/1.5/Introduction).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.