Page 1 of 1

Custom Fields per Item in Products admin

Posted: Mon May 13, 2013 1:02 pm
by howey
Hi

I am building an online shop with various products. As there are broadly 6 different groups of products, each group has numerous distinct characteristics. If I create custom fields to cater for all these characteristics there will probably be about 50 fields across the different groups. From an admin point of view this is going to make adding new items tricky ie finding the right fields to add data to. Human error dictates that sooner or later the wrong fields are going to be populated.

My question is, has anyone tried modifying/organising the products module so that when adding an item, only the fields relevant to that group are shown? I have avoided using the terms hierarchy and category, although I am assuming that these functions could be used to display the correct fields for that group of products.

This is about modifying the admin system, not the front end display. I think the relevant fields can be sorted through the templates system for the front end display.

If I'm barking up he wrong tree, please let me know.

:-)

Re: Custom Fields per Item in Products admin

Posted: Mon May 13, 2013 1:18 pm
by Rolf
You could change the admin templates of the module without problems: http://docs.cmsmadesimple.org/customizi ... -templates

grtz. Rolf

Re: Custom Fields per Item in Products admin

Posted: Mon May 13, 2013 2:13 pm
by howey
Hi

I had thought about modifying the original template files (if I can find the right bits), but was a bit nervous about altering the original.

The link seems to imply that you can edit a copy and that this overrides the original. However, one simple question, where is the module_custom? I can't see it in the modules directory, is this an additional element that I need to install? I've got 1.11.4 installed.

Or, do I create the directory module_custom and change some code somewhere so that directory is read instead of the templates dir.

I love CMSMS, but as a non tech designer a little knowledge can be a dangerous thing!

Re: Custom Fields per Item in Products admin

Posted: Mon May 13, 2013 3:31 pm
by Wishbone
It can be done, but it's not a simple procedure.

Create all the custom fields. Create tpl files in module_custom for the add/edit (if they are separate), have this template call a UDT, then include the normal template.

In this UDT, you can detect which category, or hierarchy or whatever, to determine which set of custom fields you want to use. Modify whatever smarty variable that contains the custom field HTML to remove the ones not needed. When the original template is called, only the fields you wanted will be selected.

If you want to be even more clever, prefix the field names with the group name so that you can define new custom field groupings on-the-fly without having to edit your UDT.. In the UDT, remove the prefix so that it makes more sense to the user.

I did something slightly similar once, where I added GBFilePicker to the News module.

http://forum.cmsmadesimple.org/viewtopi ... =7&t=52913

It's also possible to use this technique for modules that have limited custom field types to expand the selection of types.

Re: Custom Fields per Item in Products admin

Posted: Mon May 13, 2013 3:37 pm
by calguy1000
I would do it in module_custom but with some jquery to hide some custom fields based on the selected category/hierarchy/phase-of-the-moon/weekday

Re: Custom Fields per Item in Products admin

Posted: Tue May 14, 2013 8:10 am
by howey
Thanks for the feedback. It looks like I will be able to achieve the result I was looking for. However, I may be swimming in deep water for me. I'll have a fiddle around to see where I get, at least I'll learn a bit more.

It never ceases to amaze me on how helpful people are on CMSMS. Everytime I think I may have to swap to another system; in this case a bespoke shopping cart, CMSMS seems to come up with the answer.

Thanks again for the advice.