The Joomla! Forum ™






Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sun Jan 13, 2008 10:54 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 03, 2008 11:39 am
Posts: 9
Hi, am here again...trying to complete a second project (harder on this time, I think :pop)

Wish me good luck....


Last edited by AmyStephen on Mon Feb 04, 2008 8:19 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Jan 13, 2008 6:02 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Nov 29, 2007 9:41 pm
Posts: 141
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

_________________
http://joomlacode.org/gf/project/jkids/ Joomla! Kids - the Project aimed at making Joomla! more kid friendly!


Top
 Profile  
 
PostPosted: Sun Jan 13, 2008 6:17 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 03, 2008 11:39 am
Posts: 9
Thank you for your response! 8) 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?


Top
 Profile  
 
PostPosted: Sun Jan 13, 2008 7:28 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Nov 29, 2007 9:41 pm
Posts: 141
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

_________________
http://joomlacode.org/gf/project/jkids/ Joomla! Kids - the Project aimed at making Joomla! more kid friendly!


Last edited by shantanubala on Sun Jan 13, 2008 7:34 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Jan 14, 2008 8:03 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu Aug 18, 2005 8:57 am
Posts: 1382
Location: Shrewsbury, Shropshire, United Kingdom
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.

_________________
Chris Davenport - Joomla Production Leadership Team

Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/


Top
 Profile  
 
PostPosted: Mon Jan 14, 2008 8:36 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 03, 2008 11:39 am
Posts: 9
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


Top
 Profile  
 
PostPosted: Wed Jan 23, 2008 6:31 pm 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
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

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


Top
 Profile  
 
PostPosted: Tue Jan 29, 2008 1:57 am 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
tungolcild -

We are reminding people that this is the last week of the contest.

Thanks!
Amy :)

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 



Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group