---
title: "Joomla 2.5 Templates &#8211; JFactory::getDocument()"
description: "In our continued effort to review the PHP code in the Joomla 2.5 Beez2 template, we come across the following code: // get params $color = $this-&gt;params-&gt;get('templatecolor'); $logo =..."
url: https://www.inmotionhosting.com/support/edu/joomla/joomla-2-5/jfactory-get-document/
date: 2012-07-19
modified: 2021-08-16
author: "Brad Markle"
categories: ["Joomla", "Joomla 2.5"]
tags: ["Joomla v2.5"]
type: post
lang: en
---

# Joomla 2.5 Templates &#8211; JFactory::getDocument()

In our continued effort to [review the PHP code in the Joomla 2.5 Beez2 template](/support/website/working-with-images-in-premium-web-builder/), we come across the following code:

// get params
$color = $this->params->get('templatecolor');
$logo = $this->params->get('logo');
$navposition = $this->params->get('navposition');
$app = JFactory::getApplication();
**$doc = JFactory::getDocument();**

Our specific focus in this article will be $doc = JFactory::getDocument().

## What is getDocument?

According to official documentation, getDocument returns the global document object as a JDocument object type. Our next step is to find out what is contained within this global document object.

## What is included within JDocument?

Because we want to find the contents of JDocument, which is put into the $doc variable, we will adjust our template's index.php to print out this data.

| Updated Code | Screenshot of the contents of $doc |
| --- | --- |
| // get params $color = $this->params->get('templatecolor'); $logo = $this->params->get('logo'); $navposition = $this->params->get('navposition'); $app = JFactory::getApplication(); **$doc = JFactory::getDocument();** $templateparams = $app->getTemplate(true)->params; **echo "<pre>"; print_r($doc); echo "</pre>"; die();** | [![jdocumenthtml](https://www.inmotionhosting.com/support/wp-content/uploads/2012/07/edu_joomla25_create-template_jdocumenthtml.gif)](/support/wp-content/uploads/2012/07/edu_joomla25_create-template_jdocumenthtml.gif) |
| Contents of $doc |
| JDocumentHTML Object ( [_links] => Array ( => Array ( => alternate => rel => Array ( => application/rss+xml => RSS 2.0 ) ) => Array ( => alternate => rel => Array ( => application/atom+xml => Atom 1.0 ) ) ) [_custom] => Array ( ) => beez_20 => /joomla25 => JRegistry Object ( => stdClass Object ( => 53 => 72 => images/joomla_black.gif => Joomla! => Open Source Content Management => left => personal ) ) [_file] => /home/inmoti6/bradm.inmotiontesting.com/joomla25/templates/beez_20/index.php [_template:protected] => [_template_tags:protected] => Array ( ) [_caching:protected] => => My New Page Title => This is my custom Meta Description => => https://bradm.inmotiontesting.com/joomla25/ => en-gb => ltr [_generator] => Joomla! - Open Source Content Management [_mdate] => [_tab] => [_lineEnd] => [_charset] => utf-8 [_mime] => text/html [_namespace] => [_profile] => [_scripts] => Array ( => Array ( => text/javascript => => ) => Array ( => text/javascript => => ) => Array ( => text/javascript => => ) => Array ( => text/javascript => => ) => Array ( => text/javascript => => ) => Array ( => text/javascript => => ) ) [_script] => Array ( => window.addEvent('load', function() { new JCaption('img.caption'); }); ) [_styleSheets] => Array ( => Array ( => text/css => => Array ( ) ) => Array ( => text/css => => Array ( ) ) ) [_style] => Array ( ) [_metaTags] => Array ( => Array ( => text/html ) => Array ( => joomla 2.5 testing, metadata options, meta keywords, learn joomla, joomla 2.5 tutorial => => index, follow ) ) [_engine] => [_type] => html [_errors:protected] => Array ( ) ) |

As you can see in the data above, the $doc variable has information about:

1. RSS feeds within the page
2. Site information, such as the title and description
3. References to .js javascript and .css CSS files being loaded
4. ... and more

## How is $doc / JDocument used within the template?

The only reference to $doc in this particular template is in the following code:

$doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript/md_stylechanger.js', 'text/javascript', true);

Based upon **addScript**, it appears we are telling Joomla to load another javascript file into the page, */javascript/md_stylechanger.js*.
