092 - Write a document on PHP essentials for template designers.
-
- Joomla! Apprentice
- Posts: 9
- Joined: Thu Jan 03, 2008 11:39 am
- Contact:
092 - Write a document on PHP essentials for template designers.
Hi, am here again...trying to complete a second project (harder on this time, I think )
Wish me good luck....
Wish me good luck....
Last edited by AmyStephen on Mon Feb 04, 2008 8:19 am, edited 1 time in total.
-
- Joomla! Enthusiast
- Posts: 141
- Joined: Thu Nov 29, 2007 9:41 pm
Re: 092 - Write a document on PHP essentials for template designers.
Hey! If you need any help, just let me know. I've been working with 1.5 templates a lot lately and would be glad to help.
Good luck!
-Shantanu
Good luck!
-Shantanu
http://joomlacode.org/gf/project/jkids/ Joomla! Kids - the Project aimed at making Joomla! more kid friendly!
-
- Joomla! Apprentice
- Posts: 9
- Joined: Thu Jan 03, 2008 11:39 am
- Contact:
Re: 092 - Write a document on PHP essentials for template designers.
Thank you for your response! On the otherside I have not so much experience with templates...I have downloaded some from different sources and looking at the code....What do you believe are the most important (php) elements for a template designer?
-
- Joomla! Enthusiast
- Posts: 141
- Joined: Thu Nov 29, 2007 9:41 pm
Re: 092 - Write a document on PHP essentials for template designers.
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.
it returns template's directory for linking images, stylesheets, and javascript files.
A good example of this is
---------------------
Another good php variable is
which returns the url of the Joomla installation (i.e. http://yourjoomlasite.com)
An example is
Another version of this is the variable, which returns a relative path to the joomla install without the "http://yoursite.com"
---------------------
A noteworthy variable for templates is:
Used for the current state of modules in a PHP conditional such as
---------------------
This variable: 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:
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-->
---------------------
Lastly you can define specific template functions for different levels of users, guests, administrators, etc.
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
Code: Select all
$this->template
A good example of this is
Code: Select all
<img src="templates/<?php echo $this->template; ?>/images/something.png">
Another good php variable is
Code: Select all
JURI::base()
An example is
Code: Select all
<a href="<?php echo JURI::base(); >">Home</a>
Code: Select all
$this->baseurl
---------------------
A noteworthy variable for templates is:
Code: Select all
$this->countModules('condition')
Code: Select all
<?php if($this->countModules('user3')) : ?>
<div id="topbar">
<jdoc:include type="modules" name="user3" style="xhtml" />
</div>
<?php endif; ?>
This variable:
Code: Select all
JRequest::getVar('view')
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: Select all
<?php if(JRequest::getVar('view') == ('article') { ?>
[Insert whatever here]
<?php } else { ?>
[Insert whatever here]
<?php } ?>
This frontpage option is this conditional-->
Code: Select all
<?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: Select all
<?php
$theuser = JFactory::getUser();
$usertype = $theuser->get('[Insert attribute here]')
if($usertype == '[Insert attribute value here]') { ?>
[Insert whatever here]
<?php } ?>
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
Last edited by shantanubala on Sun Jan 13, 2008 7:34 pm, edited 1 time in total.
http://joomlacode.org/gf/project/jkids/ Joomla! Kids - the Project aimed at making Joomla! more kid friendly!
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: 092 - Write a document on PHP essentials for template designers.
Hi,
I don't want you to go off on a tangent with this task. Read the task description carefully. The idea is that many people who work on Joomla! templates are designers, such as graphic artists, who have little or no knowledge of the PHP language. You can assume that they have at least a basic knowledge of HTML/CSS. If you scan the template forums you will often see questions about PHP itself. So this task is just a basic introduction to the kinds of PHP statements that are commonly seen and used in templates. It's not about Joomla!, its API or any of the variables that you have access to. That should be documented elsewhere.
So, for example, you will need to explain about the tags; the echo/print statement; if-then-else constructs and so on. It doesn't need to be hugely detailed; we're not looking for a PHP reference manual here. Keep the target audience in mind and show them what they need to know about PHP so they can get their jobs done.
Hope that clarifies.
Any questions, just ask.
Chris.
I don't want you to go off on a tangent with this task. Read the task description carefully. The idea is that many people who work on Joomla! templates are designers, such as graphic artists, who have little or no knowledge of the PHP language. You can assume that they have at least a basic knowledge of HTML/CSS. If you scan the template forums you will often see questions about PHP itself. So this task is just a basic introduction to the kinds of PHP statements that are commonly seen and used in templates. It's not about Joomla!, its API or any of the variables that you have access to. That should be documented elsewhere.
So, for example, you will need to explain about the tags; the echo/print statement; if-then-else constructs and so on. It doesn't need to be hugely detailed; we're not looking for a PHP reference manual here. Keep the target audience in mind and show them what they need to know about PHP so they can get their jobs done.
Hope that clarifies.
Any questions, just ask.
Chris.
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
-
- Joomla! Apprentice
- Posts: 9
- Joined: Thu Jan 03, 2008 11:39 am
- Contact:
Re: 092 - Write a document on PHP essentials for template designers.
Nice. So I will make a list with what my document will cover (I have already done some things) and I will upload here a first draft..Thank you
-
- Joomla! Champion
- Posts: 7018
- Joined: Wed Nov 22, 2006 3:35 pm
- Location: Nebraska
- Contact:
Re: 092 - Write a document on PHP essentials for template designers.
tungolcild -
If you get a chance, can you please let us know where you are at on this task? It's been over a week since we have heard from you.
Thanks!
Amy
If you get a chance, can you please let us know where you are at on this task? It's been over a week since we have heard from you.
Thanks!
Amy
-
- Joomla! Champion
- Posts: 7018
- Joined: Wed Nov 22, 2006 3:35 pm
- Location: Nebraska
- Contact:
Re: 092 - Write a document on PHP essentials for template designers.
tungolcild -
We are reminding people that this is the last week of the contest.
Thanks!
Amy
We are reminding people that this is the last week of the contest.
Thanks!
Amy