The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
PostPosted: Mon Feb 06, 2012 9:09 pm 
Joomla! Intern
Joomla! Intern

Joined: Sat Feb 02, 2008 4:06 pm
Posts: 50
Location: France
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:
// 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);
    }
}


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;
    }
}


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>


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>



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


Thanks for the help ! :)


Top
 Profile  
 
PostPosted: Wed Aug 08, 2012 10:36 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jun 09, 2011 1:55 am
Posts: 10
Check the "Creating a custom form field type" official tutorial: http://docs.joomla.org/Creating_a_custom_form_field_type

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

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 



Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group