1

I am trying to create extra fields on the Jomsocial Groups Create New Group page, its suggested on the Jomsocial docs that the best way is to creat a plugin to do this.

As I have never created such a complex plugin do anyone have a working example to start with?

Here is the code that I have tried with

    <?php
defined('_JEXEC') or die('Restricted access');
if (! class_exists ( 'plgSpbgrouppostcode' )) {
class plgSpbgrouppostcode extends JPlugin {
/**
* Method construct
*/
function plgSystemExample($subject, $config) {
parent::__construct($subject, $config);
// JPlugin::loadLanguage ( 'plg_system_example', JPATH_ADMINISTRATOR ); // only use if theres any language file
include_once( JPATH_ROOT .'/components/com_community/libraries/core.php' ); // loading the core library now
}

function onFormDisplay( $form_name )
{
/*
Add additional form elements at the bottom privacy page
*/
$elements = array();
if( $form_name == 'jsform-groups-forms' )
{
$obj = new CFormElement();
$obj->label = 'Labe1 1';
$obj->position = 'after';
$obj->html = '<input name="custom1" type="text">';
$elements[] = $obj;

$obj = new CFormElement();
$obj->label = 'Labe1 2';
$obj->position = 'after';
$obj->html = '<input name="custom2" type="text">';
$elements[] = $obj;

}

return $elements;
  • does this work (does it show the two extra fields)? It seems you'd still have to save those fields somehow... – Riccardo Zorn Feb 07 '13 at 21:27
  • I am afraid that nothing is shown. It doesn't help that I can work out how to find the form name as the example on the Jomsocial relates to one I can't find anyway. – Steve Brown Feb 08 '13 at 09:28
  • Maybe their proposed solution is old. But for getting your head around it why don't you try to achieve this editing the group.xxx.php in your template and do a core hack in the backend. once it works, you can write a plugin to parse the input fields or try to catch them in the next template... ugly but no core hacks in this case. To sum up: add the fields through the template, 2. do a core hack to save them, 3. once you know the names etc. write a plugin or edit the next template file to handle it... you might be able to pull it off. – Riccardo Zorn Feb 09 '13 at 08:56
  • Thanks Riccardo, in the end I used a Fabrik form embedded inside a module position inside a new task page. I used this tutorial http://www.minitek.gr/tutorials/jomsocial-tutorials/item/10-how-to-create-a-new-task-page-in-jomsocial.html and put a module position on that page Thanks Steve I do think that the ability to add new feilds to a Group creation form should be a core feature – Steve Brown Feb 09 '13 at 14:24

0 Answers0