I'm working on creating a small plugin to modify the Category Forms (on the add/edit category view) in Joomla.
I was able to use the tutorial on Joomla's site to modify the forms on User Profiles, Articles, and Menus; however, Categories do not seem to work properly.
This the code that I am using:
defined('JPATH_BASE') or die;
class plgContentCategoryType extends JPlugin {
function onContentPrepareForm($form, $data) {
// Load plugin language
$lang = JFactory::getLanguage();
$lang->load('plg_content_categorytype', JPATH_ADMINISTRATOR);
if (!($form instanceof JForm)) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
if (!in_array($form->getName(), array('com_categories.category'))) {
return true;
}
if ($form->getName()=='com_categories.category') {
// Add the fields to the form.
JForm::addFormPath(dirname(__FILE__).'/forms');
$form->loadFile('categorytype', false);
}
}
}
and this is what the form XML looks like:
<form>
<fields name="params">
<fieldset name="categorytype" label="PLG_CONTENT_CATEOGRYTYPE_FIELDSET_LABEL">
<field name="category_type" type="list" label="PLG_CONTENT_CATEGORYTYPE_LABEL" description="PLG_CONTENT_CATEGORYTYPE_DESC">
<option value=""></option>
<option value="features">PLG_CONTENT_CATEGORYTYPE_FEATURES</option>
<option value="columns">PLG_CONTENT_CATEGORYTYPE_COLUMNS</option>
<option value="spotlights">PLG_CONTENT_CATEGORYTYPE_SPOTLIGHTS</option>
<option value="slices">PLG_CONTENT_CATEGORYTYPE_SLICES</option>
<option value="news">PLG_CONTENT_CATEGORYTYPE_NEWS</option>
</field>
</fieldset>
</fields>
</form>
Any help in what I'm doing wrong would be greatly appreciated! Like I said, it will work on any other type of content, for instance, for it to work on menu's, just have to change the 'name' in the code.
thanks!