Joomla Template Tutorial (Part 3)

This is Part 3 of the Joomla Template Tutorial series. Part 1 is here, and Part 2 is here.

By now, you should have entered all the necessary code for your Main Body & Module Positions.

8. Enter the code for the “header” tags

We’re still not done yet with index.php. Make sure that this file is still open in your text editor.

Now, delete the code from the beginning of the file until the <head> tags.

Replace it with the code below:


<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php $iso = split( '=', _ISO ); echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>'; ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
<?php mosShowHead(); ?>
<?php if ( $my->id ) { initEditor(); } ?>
<meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
<link href="<?php echo $GLOBALS[mosConfig_live_site]; ?>/templates/<?php echo $GLOBALS[cur_template]; ?>/css/template_css.css" rel="stylesheet" type="text/css" />
</head>

9. Change paths of all images

Now we need to change the paths of your images. If you notice, your image tags have the following format: <img src="images/filename.gif" />

This will create problems when your template is installed, because when you upload your template, the paths to your images will change, depending on where Joomla installed your template.

Thankfully, there is an easy way go around this. You need to use the Find & Replace function of your text editor.

Find all instances of this code snippet:

<img src="images/

And replace it with this:


<img src="<?php echo $GLOBALS[mosConfig_live_site];?>/templates/<?php echo $GLOBALS[cur_template];?>/images/

Your code should now look something like this:

Save your modifiedindex.php file.

10. Create the XML file.

You will need to create an XML filewhich will contain information about your template. This is also required by Joomla, because Joomla looks for this XML file when you install a template from the Administrator.

Open your favorite text editor, and create a new document. Paste the following code:


<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall type="template" version="1.0.0">
<name>template_name</name>
<creationDate>date</creationDate>
<author>author_name</author>
<copyright>copyright_info</copyright>
<authorEmail>author_email</authorEmail>
<authorUrl>author_url</authorUrl>
<version>template_version</version>
<description> template_description</description>
<files>
<filename>index.php</filename>
<filename>template_thumbnail.png</filename>
</files>
<images>
<filename>images/image_filename</filename>
<filename>images/image_filename</filename>
</images>
<css>
<filename>css/template_css.css</filename>
</css>
</mosinstall>

We’re not done yet. You need to replace the highlighted words with the following:

What Replace with
template_name Name of your template
date Date that you created your template
author_name Your name
copyright_info Copyright information of your template. Example: GNU/GPL, etc.
author_email Your email address where people can contact you.
author_url Your website’s URL.
template_version Version of your template. If this is the first time you modified your template, you can just put 1.0
template_description Brief description about your template.
image_filename Filenames of all the images you used in your template. Double check with your /template_name/images folder to make sure that you got all the filenames correctly.

If you have more than 2 images, simply add another line of <filename>images/image_filename</filename>

Your XML file should now look something like this:

Save the file as templateDetails.xml and place it in the root of your template directory.

11. Create template thumbnail

Template thumbnails allows you to preview your template from the Joomla Administrator. If you plan to distribute your template to other users, it is highly recommended that you create one.

To create a thumbnail, take a screenshot of the mockup you made previously.

Resize this screenshot to approximately 200px by 200px. Then save this as template_thumbnail.png in your template directory.

Alternatively, you can use a blank thumbnail in the meantime. I usually just use a blank thumbnail while I’m developing a template, & just make the screenshot afterwards. You can click here to download the blank template thumbnail that I use.

Note: If you don’t want to use the .PNG extension (for example, you want to save it as template_thmubnail.GIF), make sure that you also change the filename in your templateDetails.xml.

12. Review your directory structure

It’s time to review the directory structure. Please make sure that all the files are in their proper folders. You might want to double check your XML file, too.

13. Zip it

We’re almost done. Now zip your entire template directory. You can use your favorite compression utility such as WinRAR, WinZIP, IZArc.

You can also use Windows’ built-in compression: Right click on your template folder, select Send To > Compressed (zipped) Folder.

You should now have a file called template_name.zip (or in my case, chette_v5.zip)

14. Install

Finally, it’s time to put your template on a test drive.

  1. Login to your Joomla Administrator.
  2. From the menu, navigate to Site > Template Manager > Templates.
  3. Click New.
  4. You will now be asked to install your template. Look under Upload Package File.
  5. Click Browse, & locate your zipped template in your computer.
  6. Click Upload File & Install.
  7. If all goes well, a success message will be displayed. Click Continue.
  8. You will be brought back to the Template Manager.
  9. Select your new template from the list (click on the radio button), & select Assign.

Now preview your template by going to your website’s public URL. You can also preview it by going to Site > Preview > In New Window

15. Finishing touches

Now that you have finally installed your template, you probably would need to make some minor changes to your index.php or template_css.css files. Joomla provides a convenient way to do this. Simply go to the Template Manager, select your template, and click either Edit HTML or Edit CSS.

Some of you may have created unique names for your module positions that are not set by default in Joomla. For example, if you have a module position called my_module:


<?php mosLoadModules ( 'my_module' ); ?>

If this is the case, you need to define my_module in Joomla:

  1. Login to your Administrator, and from the menu, navigate to Site > Template Manager > Module Positions.
  2. Select an empty textbox under Position, & type my_module.
  3. Click Save.

And finally, you can now play with your modules, most especially your menu items. This is the most enjoyable part of template development – there’s nothing like seeing your template take shape in real time.

You might also want to check out this article: Module Basics: Putting custom HTML content on the sideblocks. It’s a pretty old article, & was written for Mambo, but most of the concepts still apply with Joomla 1.0.12.

16. The end

It’s been a long ride writing this Joomla Template Tutorial, but I sincerely hope you enjoyed this.

Please feel free to give the link to this article to those who you think will benefit from it. Should you have any corrections or suggestions, just contact me or post in the comments below.

If you were able to develop your template thru this tutorial, just send the URL over. I’d love to take a peep.

I also would like to recommend that you join us in the Joomla Forums. There’s a sub-forum over there dedicated solely on template development. You’ll love the community, & I personally have gotten a lot of invaluable advice from it.

Thank you for taking the time reading this series.


Comments

82 responses to “Joomla Template Tutorial (Part 3)”

  1. ricci555 Avatar
    ricci555

    Thanks! Was waiting for this! 🙂

  2. Dj vibri Avatar
    Dj vibri

    Hi,

    nice tutorial. I need to create a website for an artist, take a look at http://www.koenvanmechelen.be , but in plain html (with divs etc) it’s much beautifull … Hope the artist is happy with this result :-\

    Cheers,

    Pieter

  3. JeanBio Avatar
    JeanBio

    Best Joomla template tutorial I have ever seen. Thank you Chette.

  4. this one is nice.. thanks chette

  5. albaner Avatar
    albaner

    wie geht es euch leute

  6. William Northern Avatar
    William Northern

    Hey there!
    Thanks for the great tutorial. Extremely helpful and very well written

    Good job.
    Northern.

  7. Thanks for this..But template layout using table is not standard layout. M I right?

  8. Calvin Avatar
    Calvin

    Thank you so much for the excellent guide =))))))))))))))

  9. Trish Avatar
    Trish

    Thank you so much Chette – I’ve been trying to get to grips with templates and you just tell me what I need to know! You are so logical with how you explain the modules that I now think I can “Joomlify” my existing site by just tweaking my CSS and PHP code. Best of luck!

  10. Bad Credit Loan Avatar
    Bad Credit Loan

    Thanks for taking the time chette.

  11. desiree Avatar
    desiree

    heey ikm wil met leuken jongens van tussen 18 en 25 jaar oud kom met me plaaten als je wilt groetjes desiree ik ben een leuke meid

  12. Samir Aghayev Avatar
    Samir Aghayev

    I would like to thank the webmaster of this site for such a wonderful tutorial!!!

    What I wanted to learn for months, I learned literally in an hour!

    Thanks much again!

    Regards,

    Samir

  13. dylan Avatar
    dylan

    italien ist welt meister geworden.

  14. dylan Avatar
    dylan

    die beste manschaft ist italien

  15. Chette Soriano Avatar
    Chette Soriano

    Aw thanks for the very kind words

  16. al (jacksonville, florida, usa) Avatar
    al (jacksonville, florida, usa)

    Thanks so much for your great documentation. Wonderfully done.

  17. Dear can u tell me the way add several banners to my template

  18. ALright! Well done to such a great tutorial. Really good, simple down to earth.
    Keep up the good work Chette.
    God bless you!

  19. Thank you so much for this tutorial! I was so confused about how to publish and position modules in the correct places in the index.php file. When you said that multiple modules could be placed in the same module position, how it worked just clicked into place! :-*

  20. DaKreator Avatar
    DaKreator

    Great tutorial, many thanks for this work and for sharing your knowledge with us! Just one question: Is it possible to use ‘divs’ instead of ‘tables’ and the template to work?

  21. excellent, thanks for the lesson

  22. I have been looking for a long time for a tut like this, have found mambo ones with Dreamweaver plugins. I am more of a designer then programer and its tough. This really helps. Just curious how you would go about making drop down menus with your tut? I have been through joomla forums alot and making a custom menu has bugged me. Thanks!!

  23. Chette,

    This note is my thanks for you public spirited effort in making this tutorial availabl. I have been in IT for over 40 years & today an an Enterprise Architect. It is very hard these days to learn every aspect of the multitude of fantastic software available to us (Apache, Tomcat, RubyOnRails, Ajax technology, WikiMedia, Bloggs, Bulletin Boards, Joomla (let alone all the prior web tools).

    You really have allowed me to come up to speed in hours rather than days of tedious reverse engineering.

    The concise clear and to-the-point handling of this topic are an excellent testimony to the way you think and explain things.

    My heartfelt thanks – Doug M – Sydney Australia

  24. great tutorial thanks cabayan ! ;D

  25. pothound Avatar
    pothound

    thanks a mill! searched and read many tuts but nothing made sense. i was even able to make a tableless template for joomla! well it had to be written by a woman ;D
    now i will have to find something as good as that for the modules. yours does not match my current joomla.
    thanks again!

  26. I created template for Joomla 1.5, by reading your and compassdesigns tutorials, but I can’t install it. Joomla write that can find xml installiation

    What it can be? Who could me answer?

  27. papamiller Avatar
    papamiller

    I would love someone to update to support Joomla 1.5 stable.

    Nice tutorial!!

  28. Great work, Chette! Easy to understand tutorial!

    Cheers! 😉

  29. great tutorial… easy to understand… 😀

  30. Olivier Avatar
    Olivier

    Here’s what i did thanx to your tutorial. It’s my first template. I did it in full CSS, no tables!
    http://doumchak.free.fr
    Thanx again for your sharing, Chette.
    Olivier

  31. Milan Dizajn Avatar
    Milan Dizajn

    Thanks chette, this is very good tutorial.

    Milan Dizajn

  32. Olivier Avatar
    Olivier

    The really really best joomla! template tutorial ever!!
    Many other tuts are either too complex or too vague. This one’s clear straightforward and can be easyly understood when you need a start.
    The only objection would be: why do you choose tables instead of css layout?
    Olivier.
    When i have my template set i’ll let you know.
    Many many thanx for this tutorial!!

  33. Greetings from Serbia. Thanks for making this nice newbie – friendly tutorial. Seems so easy 🙂

  34. Great tutorial! Thanks. /Carl

  35. Soko Banja Avatar
    Soko Banja

    Thank you for this tutorial

  36. hello i am balaji i did this in my local server

    but the out put is “Direct Access to this location is not allowed.”

    i don’t Why this happen can any one help me!

  37. conquer Avatar
    conquer

    real best joomla! template tutorial ever ))

  38. sezer Avatar
    sezer

    CSS “Cascading Style Sheets” Lessons – web design lesson – – Web site : http://css-lessons.ucoz.com/index.html

  39. dagohoy Avatar
    dagohoy

    Nice tutorial “ganda talaga pag pinay” hehe thanks, for the tutorial you really made a newbie to be a little prof.

  40. tatanajllo Avatar
    tatanajllo

    What a great tutorial it really did it for me! Thanks soo much!

  41. Bob N. Betts Avatar
    Bob N. Betts

    Nice tutorial. I wish Chette would make a tutorial specifically CSS Guide for Joomla.

  42. xxcemil Avatar
    xxcemil

    HI i need your help i really want to create my own website/web page but i dont know how to go about doing it so can you please help me out

  43. irawan Avatar
    irawan

    Thanks for the course. Can you please send me the pdf version with the animated version to my email?? thanks before.

  44. mommyj Avatar
    mommyj

    Hi, Thanks so much for this… i thought i would have to go to several sites to figure this out, this one visit to your site is enough for me. It was very easy to understand and follow.

    God Bless you for your generosity.
    ;D

  45. Mathan Avatar
    Mathan

    Wow… that’s really awesome dude…
    it’s really easy to understand……just a visit it’s cure my sickness….great

  46. Nice tuts! Is it possible to use this tuts’ using joomla 1.5? I’m just a newbie in joomla. tnx

  47. Nice tutorial! Iba talaga kapag pinoy!

  48. Thanks very much for these tutorials. These are the only ones that actually helped me with creating a custom template. I have a working one, but if you want the URL, email me for it.

    Thanks again.

    Cade

  49. Stephen Avatar
    Stephen

    Thanks man this is just what I was looking for!
    Best tutorial that I have come across.
    Would have been nice if you could explain the Blank CSS file and where what gets effected.

    Keep up the good work man.
    🙂

  50. Thank you very much for this tut. Like someone else said “write a book”. You are a very skilled communicator.

    After reading this tut, i now feel ready to start getting creative with Joomla.

    Japan

  51. Behnam Avatar
    Behnam

    Thanks oooooddddddddllllllleeeeeessssss ;D
    You are angel this is not a extravaganza. you are one of fundless good person who want share his knowledge. 😉

  52. bumslayer Avatar
    bumslayer

    Nice tutorial. It would even be nicer if it’s updated to Joomla 1.5.x, utilizing jdocs, with an explanation of jdoc parameters to facilitate display of modules. Just the same, the tutorials have been very helpful indeed.

    Keep up the good work!

  53. you’re the best! sana meron ka pang ibang tutorials. i’d luv to read them all! 🙂

  54. Ones more! astig!!!!

  55. Wow! What a great job! Have you thought of doing a video of this tutorial for youtube? I’m sure you would get a huge amount of hits. Thank you and I wish a brand new car for you because you deserve it after give us a gift like this tutorial. Thanks you.

  56. thanks! help alot

  57. WoW! this is excellent tutorial! very clean and straight to the point! so easy to learn… Every detail are mentioned here… 5 stars for you!

  58. Thank you very much for this tutorial,simple and written well.It allowed me to see more clearly about joomla template

    God Bless you and guides you on his way

  59. Wow..thank 4 useful tutorial.. 😀

  60. Hi chette, thanks for the tutorial, I followed your tutorial but I encountered an error:

    [b]Upload template – Upload Error
    Failed to move uploaded file to /media directory.[/b]

    please help.. thanks!

  61. I just cant the see the picture that i used. Tignan mo ng website ko para malamam mo po.

    http://uzosaminaruto.net23.net

  62. its me again.. Chette paano mag arrange ng menu? ung pa vertical?

  63. Thank you so much for this amazing tutorial.

    I have been tearing my hair out trying to learn this, thinking that Joomla! was much more difficult than I anticipated, but I was just in need of a good teacher!

    I can’t believe how easy you made everything seem.

    [b]Thank you![/b]

    Ol~

  64. just amasing for beginers 🙂 great work!!

  65. Great tutorial, wish I can have my joomla site soon.

  66. intekhab khan Avatar
    intekhab khan

    Hats off to you..
    from nearly 6 month i was searching the tutorial of joomla template(where to start)But i cant understand its basic logic.This is a brilliant tutorial 🙂

  67. Rajat Agarwal Avatar
    Rajat Agarwal

    Oh man! How flawlessly and easily you’ve explained each and everything. Where were you a year ago when I was paying to buy templates… 😛

  68. Pablo Avatar
    Pablo

    Wow. Even though this was written a while ago, it is still useful to me.

    Thank you thank you thank you!

    Greeting from Argentina 🙂

  69. thank 4 useful tutorial

  70. thanks a lot Avatar
    thanks a lot

    Thanks a lot for this tutorial!

  71. brendonalpart Avatar
    brendonalpart

    You will need to create an XML filewhich will contain information about your template. This is also required by Joomla, because Joomla looks for this XML file when you install a template from the Administrator.

  72. Error! Could not find a Joomla! XML setup file in the package.

  73. Horror Mania Avatar
    Horror Mania

    Awesome tutorial. I stumbled across it and just wanted to say thanks! You should definitely write The Definitive Guide to Joomla!

    ;D

  74. Sokobanja Avatar
    Sokobanja

    Thanx a lot.Very useful tut. and very easy to way learn something new.

  75. Soko banja Avatar
    Soko banja

    Great post. thanx

  76. Great tutorial. Thanx

  77. Thanks very much, always have energy to help the helpless.

  78. thanks for the explanation, it is of great help

  79. I suggest to use Codelobster PHP Edition with special Joomla Themplate Editor.

  80. Thank you very much. It seems like you master the art of oratory. 😉

  81. Thank you very much. This is a very cool tutorial!
    Best wishes!

  82. kone oumar Avatar
    kone oumar

    Thank you for your explanation . your tuto permit me to create my template et using whith joomla.

    God bless you

Leave a Reply

Your email address will not be published. Required fields are marked *