I'm trying to create a simple plugin that adds 4 textfields to the article options. But I'm not getting it to work.
This is my plugin structure:
extrafields.xml extrafields.php
These are the contents of the files:
extrafields.xml
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content" method="upgrade">
<name>plg_content_extrafields</name>
<version>3.6.5</version>
<description>Extra fields voor articles</description>
<files>
<filename plugin="article">extrafields.php</filename>
</files>
<config>
</config>
</extension>
extrafields.php
<?php
// no direct access
defined( '_JEXEC' ) or die;
class plgContentExtrafields 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;
/**
* Plugin method with the same name as the event will be called automatically.
*/
function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
$option = $app->input->get('option');
switch($option)
{
case 'com_content' :
if ($app->isAdmin())
{
JForm::addFormPath(__DIR__ . '/forms');
$form->loadFile('extrafields', false);
}
return true;
}
return true;
}
}
?>
Now I can install it succesfully but when I try to access the plugin it says "article.xml not found" And when I access the articles I don't see any extra fields or tabs or anything. The current documentation for adding fields are limited to contacts and it doesn't really translate well to the article component. Could someone help me out?
<folder plugin="article">extrafields</folder>
. This tutorial might help.