phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Joomla - Template: Using Parameters (Part 7)

Tag: joomla, template   Category: Web Design, PHP Framework
post: 19 Dec 2007 read: 2,612


Joomla Template Tutorial - Part 7: For more flexible design, we can use parameters in our template. So, you can provide options to change template without your users touch line codes. For example, your user can choose background color.

In this post, we try to provide background color option. Following this steps:

  1. Open templateDetails.xml within your Joomla\templates\mytemplate.
  2. Enter following bold code:
    
    <?xml version="1.0" encoding="utf-8"?>
    <install version="1.5" type="template">
    <name>mytemplate</name>
    <version>1.0.0</version>
    <creationDate>12/12/07</creationDate>
    <author>Wiwit Siswoutomo</author>
    <authorEmail>wsiswoutomo@yahoo.com</authorEmail>
    <authorUrl>http://www.phpeveryday.com</authorUrl>
    <copyright></copyright>
    <license>GNU/GPL</license>
    <description>TPL_MY_TEMPLATE</description>
    <files>
      <filename>index.php</filename>
      <filename>templateDetails.xml</filename>
    </files>
    <positions>
      <position>breadcrumbs</position>
      <position>left</position>
      <position>right</position>
      <position>top</position>
      <position>user1</position>
      <position>user2</position>
      <position>user3</position>
      <position>user4</position>
      <position>footer</position>
      <position>debug</position>
      <position>syndicate</position>
    </positions>
    <params>
      <param name="backgroundVariation" 
    type="list" default="blue" label="Background Variation" 
    description="Background color variation to use">
        <option value="blue">Blue</option>
        <option value="red">Red</option>
        <option value="green">Green</option>
        <option value="orange">Orange</option>
        <option value="black">Black</option>
        <option value="white">White</option>
        <option value="yellow">Yellow</option>
      </param>
    </params>
    </install>
    
  3. Next, create a file named "params.ini" within Joomla\templates\mytemplate. This file contents choosed value for parameters. Enter following code:
    
    backgroundVariation=blue
    
  4. Open your index.php within Joomla\templates\mytemplate. Change tag <body> become:
    
    <body bgcolor="<?php echo $this->params->get('backgroundVariation'); ?>">
    
    
    
  5. Now try to point your browser to http://localhost/joomla. You can see like following screen:
  6. Now, try to open your joomla administration. Open at Extensions > Template Manager.
  7. Click at link mytemplate:
  8. You will get template edit page. Now, focus your attention at Parameters box. Change Background Variation become Red.
  9. Click Save button on the top.
Point your browser to http://localhost/joomla. Background color has changed


Series this article:
Joomla - Template: Understanding Basic Template (Part 1)
Joomla - Template: Understanding Module Position (Part 2)
Joomla - Template: My First Template (Part 3)
Joomla - Template: Activate Template (Part 4)
Joomla - Template: Creating Layout (part 5)
Joomla - Template: Using jdoc (part 6)
Joomla - Template: Using Parameters (Part 7)
Joomla - Template: Place Text (Part 8)
Joomla - Template: Creating Preview Thumbnail (Part 9)

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting