Navigation:    Home arrow Joomla arrow Templates arrow Joomla Templates Part II
Apr 13 2006
Joomla Templates Part II PDF Print E-mail
(14 votes)
Written by Administrator   

As explained in Part One , a Joomla Template is a normal html file (with the .php extension though) with small bits of PHP in it to load the CMS data.

Example:

        <?php if ( mosCountModules( 'banner') ) { ?>
        <span class="banner"><?php mosLoadModules('banner', -1); ?></span>

This willl load ALL published modules assigned to the "banners" position -generally only the banners module- into the spot where this code appears, if there are any modules assigned. If not, nothing happens, which is useful to collapse empty module positions.

There are two Joomla functions used here:

  1. mosCountModules will check if there are any modules assigned to a specific position at all
  2. mosLoadModules will load all assigned published modules for that position sequentially in order of appearance in Module Manager admin screen.

As you may have noticed, the Count function takes only one parameter: name of the position to check modules for.

mosLoadModules

this function can take two parameters:

  1. position name to all modules for
  2. display styles (-1 in this example).
    These can be:
    0 = (default display) Modules are displayed in a column.
    1 = Modules are displayed horizontally, each in one table cell.
    -1 = Modules are displayed as raw output and without titles.
    -2 = Modules are displayed in X-Joomla format.(xhtml)
    -3 = Modules are displayed in a format that allows, for example, stretchable rounded corners by using divs.

To learn more about the display styles, please read on at the official Help site

Now we know about modules, what else is there to be pulled into the HTML skeleton from the CMS?  

Well, there are various bits of PHP commonly used to get Joomla output. The following will not be exhaustive I fear.

  1. mosShowHead

    Code: <?php mosShowHead(); ?>
    What's it do? Inserts the page title and other header information such as meta tags.
    Placement: between the head tags of the file!

  2. mosMainBody

     Code: <?php mosMainBody(); ?>
    What's it do? Loads current component output as defined by the $option parameter in the URL (which is frontpage generally on your sites homepage, see the Front vs Homepage tutorial for more info about this topic..).
    Placement: where you want the main page content to show.
    Example components:
    index.php?option=com_content in URL => content component loaded
    index.php?option=com_frontpage in URL => frontpage component loaded

  3. mosLoadComponents

    Code: <?php mosLoadComponents(component-name-without-com_-prefix!); ?>
    What's it do? Do I have to answer this one..?
    Placement: wherever you want the component to be loaded..

  4. the site name

    Code: <?php echo $mosConfig_sitename; ?>
    Result: loads the name of your site into the template, here for example "Flash and Joomla News.."
    Placement: wherever you want to display it.. generally as title.

  5. the site url

    Code: <?php echo $mosConfig_live_site;?>
    Result: gets the url path for your site
    Usage: generally used to avoid typing the full url before subsequent folder/file accesses.
    Example: <?php echo $mosConfig_live_site;?>/images/stories/someimage.jpg

  6. the WYSIWYG editor

    a word about this: loading the editor takes some time, as there are a lot of files associated with some editors, so it is best NOT to load it if not requiered.
    Now how do I know if the current user needs an editor for frontend content creation/editing?
    First criteria: is this a logged in site member? (if not, the user won't have editing rights anyway!)
    This check is normally used by most professional templates. Goes like this:
    <?php
    if ($my->id) { initEditor(); }
    ?>
    Explanation: if the variable $my has a value, we have a logged in user, so the editor is initialized. Simple as that.
    Placement: between the head tags.
    [The second criteria, which I really haven't seen used much, would be an additional check on the task: is the logged in user in view or edit mode?]

  7. Pathway

    Code: <?php mosPathway(); ?>
    What's that? Also known as "breadcrumbs", the pathway displays the linked path to the current page, as in Home>Section>Category>Item.
    Usefull to answer the common user question "where am I" (in the site structure) and provide quick access to related items.
    Placement: generally found either at the very top of the page, or after the header graphics and before the main content.
Comments (4) >> Feed

Christian Sweningsen said:

 
Dear Mr. Eyz,

I have been after learning Joomla for half a year now; putting together a major project, with no coding experience whatsoever -- but lots of project management etc. under my belt. This has included many, many hours studying usability and how-to-communicate-clearly-and-effectively; my site will only be of value to the degree it can fulfill that intention. The process has been delightful, and frustrating. It has been grand to discover the number of people who are offering tips and tutorials to pave the way.

But -- yours are far-and-away the best I've encountered, and they hardly even merit comparison, they really should be distributed as models for others to learn from. How it is that you "cut-to-the-chase" and offer what is actually needed to understand and work with the processes involved, is a marvel to behold. I have felt like a wanderer in the desert, as most writers write - sincerely, I give them that credit - about *stuff*, with little understanding of the people who might be using what they have produced.

Much, much gratitude!
September 25, 2006 | url

Joomla master said:

 
Thanks for useful tips!
October 10, 2006 | url

Isaac said:

 
The tutorials are very helpful kip it up Joomla deserve 2 b 1 ::
November 16, 2006

null said:

 
Current Template Name
$cur_template
August 09, 2007 | url
Write comment

busy
Tags: CMS, joomla, template,
Last Updated ( Saturday, 24 June 2006 )
 

Syndicate Joomla!

RSS Joomla Article Syndication

Polls

Do you want more tutorals about:
 
Home | Sitemap | Contact Us