The first section of PHP code that we see in the Beez2 template is the following:

// No direct access.
defined('_JEXEC') or die;

What is _JEXEC used for?

The first line, No direct access, is simply a PHP comment, it does not do anything. What it does tell us however is that the code below it is designed to stop the rest of the template's execution if this template file is accessed directly.

For example, if we access the Beez2 index file directly using the following url:
... we simply get a blank page. This is a security measure in place by Joomla.

We can confirm this by adjusting the code as follows:

The new code The new results
// No direct access.
defined('_JEXEC') or die("No direct access to this file allowed.");

Where is _JEXEC defined?

The _JEXEC variable is defined in the Joomla 2.5 index.php file in root directory, and is done so by the following code:

// Set flag that this is a parent file.
define('_JEXEC', 1);

We can confirm this by editing the Joomla 2.5 index file an changing the value of _JEXEC from 1 to 123456, as in:

// Set flag that this is a parent file.
define('_JEXEC', 123456);

When we edit our template file and add code to print this value, you can see the results below:

Added code to our template Results on screen
// No direct access.
echo _JEXEC;
defined('_JEXEC') or die;
Continued Education in Course 219: Joomla 2.5 Template Development Tutorial
You are viewing Section 1: Joomla 2.5 Templates - defined('_JEXEC') or die
Section 2: Joomla 2.5 Templates - $showRightColumn
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.

0 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:
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!