J1.5

Difference between revisions of "Using the core parameter types"

From Joomla! Documentation

Line 67: Line 67:
  
 
==Utilizing Core Parameters==
 
==Utilizing Core Parameters==
Now that the parameters have been added, they need to be used in the template.
+
Now that the parameters have been added, they need to be used in the Joomla! extension.
  
 
To simply display the parameter nested inside the page's content or nest it inside of CSS or Javascript, use this example:
 
To simply display the parameter nested inside the page's content or nest it inside of CSS or Javascript, use this example:

Revision as of 15:23, 19 January 2008

The "J1.5" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Core XML Parameter Types[edit]

XML parameter types allow the user to modify or change certain parts of a template, plugin, module, or component without having to edit any code - as long as these parameters are implemented by the developer of the Joomla! extension.

The XML File[edit]

Within every Joomla! extension, there is an XML file used for installation purposes. This file lists all the contents of the package, as well as various items used in the Joomla! extension.

Editing the XML File[edit]

The XML file will have contents which look similar to this (except filled with the extension's details):

<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
	<name></name>
	<author></author>
	<creationDate></creationDate>
	<copyright></copyright>
	<license></license>
	<authorEmail></authorEmail>
	<authorUrl></authorUrl>
	<version></version>
	<description></description>
	<files>
		<filename module="mod_blog_calendar"></filename>
	</files>
	<languages>
                <language></language>
	</languages>
	<params>
	</params>
</install>

Find the <params> tag first. This will be the focus of XML parameters in Joomla!.

Adding Parameters[edit]

After finding the <params> tag, place an opening (<param>) and closing (</param>) tag for the parameter in the Joomla! extension's XML file.

After placing the opening and closing tags, choose whether you want one of the following types of parameters:

  • List Parameters (parameters are changed in a drop down list)
  • Radio Parameters (parameters are changed a check-box style input)
  • Text Parameters (parameters are changed through direct text input)

List Parameters[edit]

List parameters are changed through a drop-down style list. List parameters are useful when there are multiple options or selections available to the end user of a Joomla! extension. To implement List parameters, use the following code in between the <params> and </params> tags in the Joomla! extension's XML file:

<param name="Enter the name of the parameter here" type="list" default="Set the default value for the parameter here" label="Label the parameter here" description="Put a description of the parameter here">
<option value="Enter a string or integer here">Enter the title of the list item</option>
<option value="Enter a string or integer here">Enter the title of the list item</option>
</param>

Notice the <option> tags. These are the selectable items for the end user.

Radio Parameters[edit]

Radio parameters are changed through a check-box style selection mechanism. Place the following code in between the <params> and </params> tags in the Joomla! extension's XML file (make sure you replace the values with your own preferences):

<param name="Enter the name of the parameter here" type="radio" default="Set the default value for the parameter here" label="Label the parameter here" description="Put a description of the parameter here">
     <option value="Enter a string or integer here">Enter the title of the item</option>
     <option value="Enter a string or integer here">Enter the title of the item</option>
     <option value="Enter a string or integer here">Enter the title of the item</option>
</param>

Text Parameters[edit]

Text parameters allow the end user to directly input text instead of picking from pre-defined options. Look at the example below:

<param name="Enter the name of the parameter here" type="text" default="Enter default value" label="Enter the label for the parameter" description="Enter the description of the parameter here" />

Utilizing Core Parameters[edit]

Now that the parameters have been added, they need to be used in the Joomla! extension.

To simply display the parameter nested inside the page's content or nest it inside of CSS or Javascript, use this example:

<? php echo $this->params->get('ParameterName') ?>

To use the parameter as a conditional, use the variable above with PHP conditional statements as shown below:

<?php
if($this->params->get('cPanelPermissions') == [insert string or integer here]) { ?> 
	 Do something    
<?php }; ?>