0

I have used the joomla docs to make a hello world plugin and then again the joomla docs to load the plugin within the joomla banners component.

I cant seem to load the extra tabs inside the banner edit view in the admin?

My helloworld.php

<?php
// no direct access
defined('_JEXEC') or die;

class plgContentHelloworld extends JPlugin
{
    /**
     * Load the language file on instantiation.
     * Note this is only available in Joomla 3.1 and higher.
     * If you want to support 3.0 series you must override the constructor
     *
     * @var boolean
     * @since 3.1
     */
    protected $autoloadLanguage = true;
    function onContentPrepareForm($form, $data) {
        $app = JFactory::getApplication();
        $option = $app->input->get('option');
        switch($option) {
            case 'com_banners':
                if ($app->isAdmin()) {
                    JForm::addFormPath(__DIR__ . '/forms'); // this is the path to the xml file
                    $form->loadFile('bannerfields', false); // this is the xml file
                    echo '<h1>Youre in the banners edit view!</h1>'; // this works
                }
                return true;
        }
        return true;
    }
}

?>

My helloworld.xml

<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" type="plugin" group="content">
        <name>plg_content_helloworld</name>
        <author>blah</author>
       <creationDate>2012-10-21</creationDate>
        <copyright>blah</copyright>
        <license>GNU General Public License</license>
        <authorEmail>blah</authorEmail>
        <authorUrl>blah</authorUrl>
        <version>1.0</version>
        <description>blah</description>
        <files>
                <filename plugin="helloworld">helloworld.php</filename>
                <filename>index.html</filename>
        </files>
</extension>

forms/bannerfields.xml

<?xml version="1.0" encoding="utf-8"?>
  <form>
   <fields name="params">
        <fieldset name="extrafields" label="Extra content">
            <field name="numero" type="text" size="50" default="" label="Example field" description=""  class="inputbox" labelclass="control-label"  />
        </fieldset>

       <fieldset name="extrafields2" label="Extra content 2">
            <field name="example1" type="text" size="100" default="" label="Example 1" description="" class="inputbox" labelclass="control-label" />
            <field name="example2" type="text" size="100" default="" label="Example 2" description="" class="inputbox" labelclass="control-label" />
            <field name="example3" type="text" size="100" default="" label="Example 3" description="" class="inputbox" labelclass="control-label" />
            <field name="example4" type="text" size="100" default="" label="Example 4" description="" class="inputbox" labelclass="control-label" />
        </fieldset>
  </fields>
</form> 

Thanks in advance :) John

1

Actually not an answer, but some research shows that: If you rename fields name to attribs like:

<fields name="attribs">

you can add the additional tabs (with fields) in most of the component forms:

  • com_templates.style
  • com_categories.categorycom_content
  • com_categories.categorycom_contact
  • com_contact.contact com_menus.item
  • etc...

You can add them even in com_categories.categorycom_banners, but this is not the case with com_banners.banner. It is possible to have here bug in Joomla! - see here (though only guess)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.