News:

Looking for documentation? Take a look on our wiki

Main Menu

Add extra field in Category?

Started by EvanGR, April 24, 2020, 11:09:49 AM

Previous topic - Next topic

EvanGR

Hello,

I want to achieve the following (admin):

1) Add a new input field in the product Category page. The admin will be able to type in some data and it will be saved to that category.

2) In the product page, retrieve the data from the field above (from the product's canonical category)

Can somebody outline or describe the steps to achieve this?

Thanks!

Studio 42

HI,
No trigger exist on save category.
The solution can be to create your own system, perhaps using a vmextentend plugin or a system plugin.
In your template override, you have to add a function to get the stored value.
If you need a simple value, you can perhaps use an existing category DB field
 

EvanGR

To store the value, can I not just:

1) Create the extra db table column myself (category)
2) Override category edit page to include the extra input field?

Is it more complex than it sounds?

AH

#3
Evan

see post #5 same idea for category entity just think categories not product :-)

http://forum.virtuemart.net/index.php?topic=137418.msg481235#msg481235

1. Add category table new field
2. update tables/categories to reference your new variable - note this gets overwritten every VM update - so not such a wonderful option
   var $has_medias = null;
   var $mynewfield = '';

3. adjust templates for edit category to get this field
Regards
A

Joomla 4.4.5
php 8.1

pinochico

Pls send info why do you need this customfiled for category?

How will you continue to work with it?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

PRO

On my site I have many things that are stored outside of vmart, but tied to categories & products.
I have an administrator component that I manage all the info with.
I use "Joomla component creator" https://www.component-creator.com/en/    to make an administrator extension.
Then I add all the fields I want.

For example, I have a "category feature" Table that controls the category page.
Featured product, sub category display, and even assigns custom fields by that category.