3

I am trying to tweak a module based on Joomshopping, a shopping cart extension. The module is called "mod_jshopping_categories", I want to add a field that is a dropdown list of the product categories into the module's admin page. Here is what I added to the .xml file:

<field
  name="Parent Category"
  type="category"
  default="0"
  label="Parent Category"
  description="Put in category"
  extension="com_jshopping">
</field>

However, on the back end the dropdown list is empty. To test, I change "com_jshopping" to "com_content", the back end correctly shows a list of article categories.

According to the documentation

type (mandatory) must be category.

extension (mandatory) is the name of the extension for which the categories will be retrieved. For example, to list content categories, use the value 'com_content'.

Does this mean there is no "category" in com_jshopping for the module to retrieve?

On the other hand, as a shopping cart extension, com_jshopping does have product categories. So how is this category defined programmatically?

Do I need to create a custom field type to retrieve com_jshopping's categories?

1

Joomshopping may have categories for the products, but it does not the Joomla core categories table/model for its categories. It has its own.

The categories field is for the Joomla core categories, which means it will return categories that exist in the #__categories for the selected component/extension.

Note that com_content is not the only extension that uses the Joomla categories. For example, com_contact is another extension that uses them.

Regarding 3rd party components, they can also make use of them if using them would be a good fit or use their own approach to creating a categories feature.

You can create your own Custom Form Field that will list Joomshopping categories and use it in your XML, or maybe use the SQL field to query the database directly could be sufficient for your needs.

There is also a strong possibility that Joomshopping has already its own custom "Joomshopping Categories" field type defined somewhere that you can use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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