What is the proper file for a custom field in admin-only article creation?

by Chase   Last Updated July 07, 2016 08:04 AM

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))
        return false;

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

Answers 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.

July 07, 2016 12:22 PM

Related Questions

Content-based plugin not loading

Updated July 12, 2016 08:04 AM

Custom field "article id"

Updated March 24, 2018 13:10 PM

Get custom select field options (params)

Updated October 26, 2018 00:10 AM