1

I'm pretty new to plugin creation and I've already hit a snag. I'm trying to add fields to the admin-side article creation via plugin but nothing is showing up in $params signifying proper loading and a die('testing...') in the plugin methods does not fire. Was hoping to get a fresh pair of eyes on this to see what I'm doing incorrectly.

articlepublishemail/articlepublishemail.php:

<?php
defined( '_JEXEC' ) or die;

class plgContentArticlepublishemail extends JPlugin
{
    protected $autoloadLanguage = true;

    function __construct(& $subject, $config)
    {
        parent::__construct($subject,$config);
        $this->loadLanguage();
    }

    function onContentPrepareForm($form,$data)
    {
        ...
        switch($option)
        {
            case 'com_content' :
                if ($app->isAdmin())
                {
                    JForm::addFormPath(__DIR__ . '/forms');
                    $form->loadFile('content',false);
                }
                return true;
        }
        return true
    }
}

articlepublishemail/articlepublishemail.xml:

<?xml version="1.0" encoding="utf-8"?>
...
<files>
    <folder>language</folder>
    <folder>forms</folder>
    <filename plugin="articlepublishemail">articlepublishemail.php</filename>
</files>    
<languages>
    <language tag="en-GB">en-GB.plg_content_articlepublishemail.ini</language>
</languages>      
<config>
    <fields name="params">
    </fields>
</config>

articlepublishemail/forms/content.xml:

<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="attribs">
    <fieldset name="articlepublishemail" label="PLG_CONTENT_ARTICLEPUBLISHEMAIL_FIELDSET_LABEL">
        <field
            name="email_send"
            type="radio"
            default="0"
            label="PLG_CONTENT_ARTICLEPUBLISHEMAIL_EMAIL_SEND_LABEL">
            <option value="0">JOFF</option>
            <option value="1">JON</option>
        </field>
        <field
            name="email_sendto"
            type="text"
            label="PLG_CONTENT_ARTICLEPUBLISHEMAIL_EMAIL_SENDTO_LABEL"
        />
    </fieldset>
</fields>
</form>

I've changed the names of fields and fieldsets several times trying to get something positive going and nothing. I don't entirely understand how the directory structure for a plugin is supposed to work either so that could be it...Either way, any help would be appreciated.

  • Have you enabled the plugin the via Plugin Manager? – Lodder Jul 12 '16 at 9:24
  • There is a full guide on how to do this on Joomla's website. You can find it here: docs.joomla.org/Adding_custom_fields_to_the_article_component . Have you used this guide for the implementation? – itoctopus Jul 12 '16 at 10:53
  • @itoctopus yes, I've used that among a few other guides (where applicable). – Chase Jul 12 '16 at 12:55
  • @Lodder Y'know, I got so caught up trying to code the darn thing that I completely forgot about any other steps that might be involved...Enabling the plugin might have helped. Would you kindly turn that into a formal answer so I can mark it. – Chase Jul 12 '16 at 12:59
1

Plugins, like other Joomla extensions, must be enabled in order work and the code be executed.

Please ensure you've enabled it, by going to the Plugin Manager via the Joomla backend.

| improve this answer | |

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.