For every layout there can be set of parameters defined in [layout_name].xml file. Is there any documentation for this configuration file? Where are those values stored? How can I access them?
When I'm creating menu item for 'Category Blog Layout' I can choose the category I'm referring to ('Parameters - Basic' section). Can I create similar select item for my components?
I think Joomla! 1.5 needs a good, complete and nontrivial tutorial for new component developers. Those that I've found are too simple and doesn't cover all aspects of this matter.
Parameters for layouts
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
- Drapichrust
- Joomla! Apprentice
- Posts: 6
- Joined: Wed Aug 15, 2007 8:26 pm
- Location: Silesia
- Drapichrust
- Joomla! Apprentice
- Posts: 6
- Joined: Wed Aug 15, 2007 8:26 pm
- Location: Silesia
Re: Parameters for layouts
Ok. I've found this (blind fool):
http://dev.joomla.org/component/option, ... arameters/
I have also created a JElement class for my component. Now I only need to inform Joomla! where to find it.
http://dev.joomla.org/component/option, ... arameters/
I have also created a JElement class for my component. Now I only need to inform Joomla! where to find it.
- Drapichrust
- Joomla! Apprentice
- Posts: 6
- Joined: Wed Aug 15, 2007 8:26 pm
- Location: Silesia
Re: Parameters for layouts
So, to create your custom parameter type and use it in your layout you have to:
1. create a class that extends JElement
Place this file into adminstrator/components/sdp_[component_name]/elements/ directory.
Name this file as [element_type].php
Example of czlonek.php file:
This class just creates select html tag with all items of 'czlonkowie' table.
2. create XML parameters file for your layout (name this file [layout_name].xml)
Now you can define param with argument type set to your custom type (type="czlonek"). My layout's name is 'default' so paramter's name will be 'default.xml'.
Tag named 'url' defines additional attributes that Joomla! will add to url. Inside this tag I define my custom parameter (remember to set type to your new JElement). Set name attribute of param tag to the name of your additional url parameter.
'Label' and 'description' attributes are not so important. I think that 'section' attribute is not needed in this case - I don't have any sections in my 'czlonkowie' table.
The last thing you have to to is to inform Joomla! where it can find your JElement class. All you have to do is to add addpath attribute to 'url' tag.
addpath="/administrator/components/com_[component_name]/elements"
And that's all. It works for me .
PS: If there is something wrong with my English please correct me.
1. create a class that extends JElement
Place this file into adminstrator/components/sdp_[component_name]/elements/ directory.
Name this file as [element_type].php
Example of czlonek.php file:
Code: Select all
<?php
defined('_JEXEC') or die();
class JElementCzlonek extends JElement
{
var $_name = 'Czlonek';
function fetchElement($name, $value, &$node, $control_name)
{
$db = &JFactory::getDBO();
$query = "SELECT concat(czlo_nazwisko,' ',czlo_imie) AS text, czlo_id AS value FROM #__czlonkowie"
.' ORDER BY czlo_nazwisko, czlo_imie';
$db->setQuery($query);
$options = $db->loadObjectList();
array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Czlonek').' -', 'value', 'text'));
return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'value', 'text', $value, $control_name.$name );
}
}
?>
This class just creates select html tag with all items of 'czlonkowie' table.
2. create XML parameters file for your layout (name this file [layout_name].xml)
Now you can define param with argument type set to your custom type (type="czlonek"). My layout's name is 'default' so paramter's name will be 'default.xml'.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="Członek SDP">
<message>
<![CDATA[CZLONEK DESC]]>
</message>
</layout>
<state>
<name>Standard Członek Layout</name>
<description>CZLONEK DESC</description>
<url addpath="/administrator/components/com_sdp/elements">
<param name="id" type="czlonek" section="com_sdp" default="0" label="Czlonek" description="PARAMCZLONEKSELECT" />
</url>
<params>
</params>
</state>
</metadata>
Tag named 'url' defines additional attributes that Joomla! will add to url. Inside this tag I define my custom parameter (remember to set type to your new JElement). Set name attribute of param tag to the name of your additional url parameter.
'Label' and 'description' attributes are not so important. I think that 'section' attribute is not needed in this case - I don't have any sections in my 'czlonkowie' table.
The last thing you have to to is to inform Joomla! where it can find your JElement class. All you have to do is to add addpath attribute to 'url' tag.
addpath="/administrator/components/com_[component_name]/elements"
And that's all. It works for me .
PS: If there is something wrong with my English please correct me.
Re: Parameters for layouts
You did a fine job there. Thanks for sharing this information
This day it is my wish that I helped you to live