1

Through following this guide, I've created a plugin and installed it but I am having trouble with the final step. Most guides are saying to create a template override and if I create an override for com_content/article, default.php looks like it was meant purely for user view override. This other question here has an answer suggesting the rendering be done in edit.php, which, highly suggests it's only for editing articles. Is edit.php truly the corect place? If so, will rendering it that way bypass the conditionals I have in my onContentPrepareForm method?

Here is my onContentPrepareForm method, just in case:

function onContentPrepareForm($form,$data)
{
    $app = JFactory::getApplication();
    if(!($form instanceof JForm))
    {
        $this->_subject->setError('JERROR_NOT_A_FORM');
        return false;
    }

    if($form->getName() == 'com_content.article')
    {
        if ($app->isAdmin())
        {
            JForm::addFormPath(__DIR__ . '/forms');
            $form->loadFile('content', false);
        }
    }
}
1

I don't understand why you want to do this through a plugin (maybe I'm missing something here, if I am, could you please explain).

The way I would do it, is by just overriding the edit.php in your administrator template file. In other words, you shouldn't modify the edit.php file directly, but rather copy the administrator/components/com_content/views/article/tmpl/edit.php to administrator/templates/[the-template-that-you-are-using]/html/com_content/article/edit.php and then modify the edit.php file there. Note that the hathor template already overrides the edit.php file.

| improve this answer | |
  • Thank you for your answer but some aspects of my question go unanswered: edit.php is the correct file to place the code in then? Is the method for displaying the custom field better as the render or is using the example in the Joomla docs better? Does the render method bypass conditionals? – Chase Jul 7 '16 at 13:55
  • I edited Hathor's edit.php just to see if it was active by doing some echoes and die statements but none of them fired. Are they suppressed or am I doing something wrong? – Chase Jul 11 '16 at 15:25
  • It might be that you have some caching in your administrator area. Have you deleted the browser cache? – itoctopus Jul 11 '16 at 17:25
  • After creating an override of edit.php in the Isis folder, var_dump($params) would then show up. My fields are still not showing though and a die('Testing...') within the onContentPrepareForm() method is not firing. – Chase Jul 11 '16 at 17:45

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.