We are continuing to review Joomla 2.5's Beez2 template code, and we next come accross the following code:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >

In our review thus far, we have alread seen instances of $this->, for example:


What is $this-> ?

Technically speaking, in PHP $this refers to the current object. PHP will set the contents of $this when you are inside a function of an object.

If we update our template's code as follows, we can see more information about $this:

<? echo "<pre>"; print_r($this); echo "</pre>"; die(); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >

The output above is quite long, and below we've included the first few lines only:

JDocumentHTML Object
    [_links] => Array
            [/joomla25/index.php?format=feed&type=rss] => Array
                    [relation] => alternate
                    [relType] => rel
                    [attribs] => Array
                            [type] => application/rss+xml
                            [title] => RSS 2.0

Based upon the first line, $this appears to be referring to the JDocumentHTML Object, which we touched based on in a previous article.


When is $this-> used in the Beez2 template?

When scanning the index.php file of the Beez2 template, there are several uses of $this:

Continued Education in Course 219: Joomla 2.5 Template Development Tutorial
You are viewing Section 7: Joomla 2.5 Templates - $this->
Section 6: Joomla 2.5 Templates - JFactory::getDocument()
Section 8: Joomla 2.5 Templates - $this->baseurl
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Joomla Community Google+ Hangout #3

June 3rd, 2014

Thank you @RustyJoomla for letting me speak on the Joomla Community Google+ Hangout!

Click here to watch!

Support Center Login

Social Media Login

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

1 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!