extending config.xml with plugins

Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Feb 02, 2008 4:06 pm
Location: France

extending config.xml with plugins

Post by baboon » Mon Feb 06, 2012 9:09 pm

Hello all,

I am trying to extend the xml field parameters of my module (and also the same for my content plugin) with specific external plugin, I have found this how-to, who works well under J1.5, especially the adaptation solution to the module :

http://www.teachmejoomla.net/code/jooml ... ugins.html

but i don't succeed under J2.5.

here is my module.php

Code: Select all

// Include the syndicate functions only once
require_once dirname(__FILE__).DS.'helper_plugin.php';
class JFormFieldModule extends JFormField
    public $type = 'MenuItems';
    protected function getInput()
        $db  =& JFactory::getDBO();
		$id  = JRequest::getVar( 'id', 0, '', '' );
        $cid = JRequest::getVar( 'cid', array($id), 'method', 'array' );
        JArrayHelper::toInteger($cid, array(0));
        $query = 'SELECT params FROM #__modules WHERE id='. $cid[0];
        $params = $db->loadResult();
        return mymodulePluginsHelper::getPluginParams($params);
here is my helper_plugin.php

Code: Select all

/** ensure this file is being included by a parent file */
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

class mymodulePluginsHelper {
    function getPluginParams( $params ) {
		$return = null;
		// set the plugins path
		$plugins_path = JPATH_ROOT . DS . 'modules' . DS . 'mymodule' . DS . 'includes' . DS . 'plugins';
		// load the xml config plugins
		$files = JFolder::files( $plugins_path , "^(.*)?\.xml" , false , true);
		//load the xml config plugins in the module config
        if ( count( $files ) ) {
            foreach ( $files as $key => $path ) {
				//load xml paremeters
				$myparams = new JParameter( $params , $path );
				// return html
				$params_html = $myparams->render();
				//clean html for rendering
				$params_html = substr( $params_html , 0 , -8 );
				$params_html = substr( $params_html , 65 );
				//load in return
				$return .= $params_html;
				$myparams = null;
        return $return;
the main xml file :

Code: Select all

	<fields name="params">
		<fieldset name="test">
			<field name="" type="module" default="" addfieldpath="/modules/mymodule/includes/fields"/>
		<fieldset name="another_fileds">
			<field name="test" type="spacer" default="" />
			<field name="mod_test" type="list" default="0" label="test" description="desc test">
				<option value="0">Option 1</option>
				<option value="2">Option2</option>
and the extended plugin xml :

Code: Select all

	<fieldset name="extend">
		<field name="extend desc" type="spacer" default="" />
		<field name="extendtext1" type="text" default="" label="extend text1" description="desc extendtext1" size="70" />
		<field name="extendtext2" type="text" default="" label="extend text1" description="desc extendtext1" size="70" />

The result in the backend is a warning :

Code: Select all

    Notice: Undefined property: JSimpleXMLElement::$params in D:\test\Site web\test25\libraries\joomla\html\parameter.php on line 398
Thanks for the help ! :)

Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Jun 09, 2011 1:55 am

Re: extending config.xml with plugins

Post by schartier » Wed Aug 08, 2012 10:36 pm

Check the "Creating a custom form field type" official tutorial: http://docs.joomla.org/Creating_a_custo ... field_type

It says the addfieldpath attribute must be applied to fieldsets not to fields...

Code: Select all

<fieldset addfieldpath="/administrator/components/<component name>/models/fields">



Return to “Joomla! 2.5 Beta Support”