1
votes

Since 1.6, I believe, there's a generic way to use 'categories' in your own created components. The default Joomla components also use this. For example: the contacts, newsfeeds and weblinks components all use the generic com_categories functionality to achieve categorized content.

Currently I'm creating a component which also has categories so I'd like to use the generic Joomla category functions to achieve this.

The status: Currently I've got the following:

  1. I've got a submenu 'categories' in my component which links to the generic categories component which some extra options. The options are there so the page will be redirected back to my component on save. This was pretty easy! But..

My problem: Now I'd like to add specific fields to my category, let's say: 'Category Moderator'.

So I've walked to the code of com_categories and in the following file 'administrator\components\com_categories\models\category.php' there is code (line 270) to look for specific component code, like the following:

// Looking first in the component models/forms folder
$path = JPath::clean(JPATH_ADMINISTRATOR."/components/$component/models/forms/$name.xml");

So the components looks (in my case) in the folder: administrator/components/mycomponent/models/forms/category.xml for specific component info.

Now, in the default category.xml of com_categories there's information about the edit screen, like the following:

<field
    name="title"
    type="text"
    label="JGLOBAL_TITLE"
    description="JFIELD_TITLE_DESC"
    class="inputbox"
    size="40"
    required="true"/>

So the title of the category is apparantly required..

So I thought I add a line to this file:

<field
    name="moderator"
    type="text"
    label="JGLOBAL_MODERATOR"
    description="JFIELD_MODERATOR_DESC"
    class="inputbox"
    size="40"
    required="true"/>

Except that's not enough to add the input.. So I've looked in the administrator/components/com_categories/views/category/edit.php template for hints, how to achieve this. But there's no code to add specific inputs for my component (or I'm wrong ;))..

Fields are added pretty specific like:

<li><?php echo $this->form->getLabel('title'); ?>
<?php echo $this->form->getInput('title'); ?></li>

I've also looked if I can overide the edit.php somehow, but unfortunately I haven't found it..

Short: Anyone knows how to add generic fields to the category edit page?

1
I am trying to figure out the same thing. Please post if you figure it out. Thanks.milan
Hi Milan, see my response on the anwser below. Sorry I can't help you any further.NickGreen

1 Answers

1
votes

You can do it by using plugins ( you can take a look at the built-in user profile plugin for an example: /plugins/user/profile ). But if you want to add a "Category Moderator", I think you could achieve it using ACL.