Ok, here are a few that I use *really* often. If you need some more examples, most of this code is stuff I've already written, so I'll gladly share it with you.
Code:
$this->template
it returns template's directory for linking images, stylesheets, and javascript files.
A good example of this is
Code:
<img src="templates/<?php echo $this->template; ?>/images/something.png">
---------------------Another good php variable is
Code:
JURI::base()
which returns the url of the Joomla installation (i.e.
http://yourjoomlasite.com)
An example is
Code:
<a href="<?php echo JURI::base(); >">Home</a>
Another
version of this is the
Code:
$this->baseurl
variable, which returns a relative path to the joomla install without the "http://yoursite.com"
---------------------A noteworthy variable for templates is:
Code:
$this->countModules('condition')
Used for the current state of modules in a PHP conditional such as
Code:
<?php if($this->countModules('user3')) : ?>
<div id="topbar">
<jdoc:include type="modules" name="user3" style="xhtml" />
</div>
<?php endif; ?>
---------------------This variable:
Code:
JRequest::getVar('view')
returns the the current view, or whatever the page is currently displaying (i.e. "frontpage", etc.)
This is useful for determining what action a template takes depending on what content is being viewed.
so if you want something specific to happen on the article view, you'd do something like this:
Code:
<?php if(JRequest::getVar('view') == ('article') { ?>
[Insert whatever here]
<?php } else { ?>
[Insert whatever here]
<?php } ?>
BUT for the frontpage, there is a better option SPECIFIC to only the frontpage, unlike this one which allows you to create conditionals for all the different content views.
This frontpage option is this conditional-->
Code:
<?php $menu = &JSite::getMenu(); ?>
<?php if ($menu->getActive() == $menu->getDefault()) { ?>
[Insert whatever here]
<?php } else { ?>
[Insert whatever here]
<?php } ?>
---------------------Lastly you can define specific template functions for different levels of users, guests, administrators, etc.
Code:
<?php
$theuser = JFactory::getUser();
$usertype = $theuser->get('[Insert attribute here]')
if($usertype == '[Insert attribute value here]') { ?>
[Insert whatever here]
<?php } ?>
You'll probably notice that I put a "
[Insert attribute here]" - that means to insert one of the following:
id: which is the user ID number
name: which is the username
aid: which is the user access identifier (i.e. 0 for public, 1 for registered, and 4 for special)
gid: which is the actual usergroup the user is in (i.e. 19 for author, 20 for editor, 22 for publisher, 23 for manager, 24 for administrator, and 25 for super administrator
guest: pretty self explanatory (when logged in the guest variable is 0)
usertype: which is the usertype, except it returns that usertype as a string (registered, author, editor, publisher, manager, administrator, and super administrator)
You'll probably notice that I put a "
[Insert attribute value here]" - this means take one of the return values stated above for each attribute, and use it as the qualifying value for the conditional statement.
HTH
-Shantanu