0

For example, in my table #__shopping_details I want to add two category fields so I added <field name="shopping_account" extension="com_shopping.shoppingdetails" type="category" label="COM_SHOPPING_FORM_LBL_SHOPPINGDETAIL_SHO_CAT" description="COM_SHOPPING_FORM_DESC_SHOPPINGDETAIL_SHO_CAT" hint="COM_SHOPPING_FORM_LBL_SHOPPINGDETAIL_SHO_CAT"/>

`<field name="shopping_item_category" extension="com_shopping.shoppingdetails" type="category" label="COM_SHOPPING_FORM_LBL_SHOPPINGDETAIL_SHOOPING_ITEM" description="COM_SHOPPING_FORM_DESC_SHOPPINGDETAIL_SHOOPING_ITEM" hint="COM_SHOPPING_FORM_LBL_SHOPPINGDETAIL_SHOOPING_ITEM"/>`

But it will allow me to add categories field twice which could be achieved using multiple true instead of adding two category fields which I do not want what I want is to allow adding two category fields with different categories in it respectively so the same table will have two different categories menu to add categories in it, for example, shopping_account and shopping_item_category and will have different menus to add categories in it...is it achievable in Joomla using Category field? can someone guide me on the same?
Do I need to change extension="com_shopping.shoppingdetails" and extension="com_shopping.shoppingdetails" to something else?

1 Answer 1

1

I think that the approach you're proposing should work in theory. You can add your shopping details category forms to the admin menu by adding inside your <submenu> tag something like

<menu link="option=com_categories&amp;extension=com_shopping.shoppingdetails">Shopping Details Categories</menu>

However, as far as I know this approach isn't used in Joomla components, so it may not have been tested thoroughly. Trying it out I did find this problem, but you should be able to work round this by adding appropriate category records as part of your install script. But there could well be other problems lurking.

If it all doesn't work, then you could try creating another component com_shopping1, and associating one of the categories types with it. The additional component doesn't have to do much - com_categories will just want to boot it and try to call countItems() to display the split of items by published status in the admin categories form. (There would be more to do if you're component is multilingual).

Then in your com_shopping manifest file you would include in the admin submenu element:

<submenu>
    ...
    <menu link="option=com_categories&amp;extension=com_shopping1">Shopping Details Categories</menu>
    ...
</submenu>

and in your form field definition:

<field name="shopping_item_category" 
    extension="com_shopping1"
    type="category"
    label="COM_SHOPPING_FORM_LBL_SHOPPINGDETAIL_SHOOPING_ITEM"
    description="COM_SHOPPING_FORM_DESC_SHOPPINGDETAIL_SHOOPING_ITEM"
    hint="COM_SHOPPING_FORM_LBL_SHOPPINGDETAIL_SHOOPING_ITEM"/>

For distributing your com_shopping component you'd then need to bundle it with com_shopping1 into a package - but I think this would work ok.

You could try experimenting by setting up your second type of category as a com_content category, and check that it gives you the sort of thing you need.

However, I do think your original approach is neater, if you can get it to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.