extending config.xml with plugins

167 views
Skip to first unread message

baboon

unread,
Feb 11, 2012, 6:03:58 AM2/11/12
to Joomla! General Development
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/joomla-1.5/joomla-php-developer-extending-config.xml-with-plugins.html

but i don't succeed under J2.5.

here is my module.php

[code]
// 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];
$db->setQuery($query);
$params = $db->loadResult();

return mymodulePluginsHelper::getPluginParams($params);
}
}
[/code]

here is my helper_plugin.php

[code]
/** 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;
}
}
[/code]

the main xml file :

[code]
<config>
<fields name="params">
<fieldset name="test">
<field name="" type="module" default="" addfieldpath="/modules/
mymodule/includes/fields"/>
</fieldset>
<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>
</field>
</fieldset>
</fields>
</config>
[/code]

and the extended plugin xml :

[code]
<config>
<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" />
</fieldset>
</config>
[/code]


The result in the backend is a warning :

[code]
COM_MODULES_test_FIELDSET_LABEL
Notice: Undefined property: JSimpleXMLElement::$params in D:\test
\Site web\test25\libraries\joomla\html\parameter.php on line 398
[/code]

Thanks for the help ! :)

subtextproductions

unread,
Feb 11, 2012, 11:13:34 AM2/11/12
to Joomla! General Development
JParameter is deprecated in Joomla 2.5, use JFields instead.

baboon

unread,
Feb 11, 2012, 2:14:07 PM2/11/12
to Joomla! General Development
Hello,

here is the result :

Fatal error: Class 'JFields' not found in D:\test\Site web
\test25\modules\mymodule\includes\fields\helper_plugin.php on line 27

and by the way there is nothing about this class in the
doc.jooma.org :

http://docs.joomla.org/index.php?title=Special%3ASearch&redirs=1&search=JFields

On 11 fév, 17:13, subtextproductions

Rouven Weßling

unread,
Feb 11, 2012, 4:56:27 PM2/11/12
to joomla-de...@googlegroups.com
It's called JForm, not JFields.

Rouven

> --
> You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>

baboon

unread,
Feb 12, 2012, 7:36:04 AM2/12/12
to Joomla! General Development
Hello,

ok and wish one is used in this list ?:

http://docs.joomla.org/API16:JForm

-->

//load xml parameters
$myparams = new JForm::???( $params ,
$path );

or i am totally wrong in the transposition of this class?


On 11 fév, 22:56, Rouven Weßling <m...@rouvenwessling.de> wrote:
> It's called JForm, not JFields.
>
> Rouven
>
> On 11.02.2012, at 20:14, baboon wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > here is the result :
>
> > Fatal error: Class 'JFields' not found in D:\test\Site web
> > \test25\modules\mymodule\includes\fields\helper_plugin.php on line 27
>
> > and by the way there is nothing about this class in the
> > doc.jooma.org :
>
> >http://docs.joomla.org/index.php?title=Special%3ASearch&redirs=1&sear...

baboon

unread,
Apr 28, 2012, 1:29:32 PM4/28/12
to joomla-de...@googlegroups.com
Did anyone can help me on this ?

Thanks !
> > To post to this group, send an email to joomla-dev-general@googlegroups.com.
> > To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages