Author Topic: How to give a custom field a separate title for each product?  (Read 2688 times)

gba

  • Jr. Member
  • **
  • Posts: 329
How to give a custom field a separate title for each product?
« on: December 08, 2020, 15:47:58 pm »
Hello all!

How can I give a customfield a separate title for each product?
Sure, I could create a new copy of the customfield for each product and add it to the product then.
But that seems to me not to be very reasonable.
Isn't there any way to differently configure the title of one and the same customfield with each product?

Thank you very much in advance for any useful hint!

Kind regards,
Gerald

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3725
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to give a custom field a separate title for each product?
« Reply #1 on: December 09, 2020, 10:49:59 am »
This is just an idea, turn off the display of title for the product and add a textfield before this customfield, there you can change the text as You please.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4516
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: How to give a custom field a separate title for each product?
« Reply #2 on: December 09, 2020, 12:30:56 pm »
A solution can be to generate the tittle with the product ID or name , but this need some PHP knowledge.

gba

  • Jr. Member
  • **
  • Posts: 329
Re: How to give a custom field a separate title for each product?
« Reply #3 on: December 09, 2020, 15:42:52 pm »
A solution can be to generate the tittle with the product ID or name , but this need some PHP knowledge.
Hm ... seems to be too complicated for the shop admin.
Thank you, though!

gba

  • Jr. Member
  • **
  • Posts: 329
Re: How to give a custom field a separate title for each product?
« Reply #4 on: December 09, 2020, 15:44:35 pm »
This is just an idea, turn off the display of title for the product and add a textfield before this customfield, there you can change the text as You please.
Thank you for your idea.
I created a new custom field of type 'String'.
Then I added it to the product's custom fields and entered a text.
In frontend then a selectbox is displayed with that text as an option.
What did I do wrong?

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3725
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to give a custom field a separate title for each product?
« Reply #5 on: December 09, 2020, 17:06:27 pm »
Go through the custom field settings. The are maybe not obvious, but with som trial and error you Will get it.

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4516
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: How to give a custom field a separate title for each product?
« Reply #6 on: December 10, 2020, 11:34:29 am »
If you see a select box, it's because you have set it as an input or cart custom field

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28223
  • Always on vacation
    • Jenkin Hill Internet
Re: How to give a custom field a separate title for each product?
« Reply #7 on: December 10, 2020, 13:38:04 pm »
This is what I use for a text instruction on one client site:

Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.28 PHP 7.4.14

gba

  • Jr. Member
  • **
  • Posts: 329
Re: How to give a custom field a separate title for each product?
« Reply #8 on: December 10, 2020, 17:04:56 pm »
Thank you very much for taking time to send me that screenshot.
I configured the custom field according that, except the setting 'Cart attribute' - this I set to 'Yes' to have it rendered in the cart, too.
But now I am still having the problem, that custom fields of type Y are being rendered after fields of type E in the cart.
This makes that solution approach useless.

The most flexible solution would be this new feature in the product backend, custom fields tab:  #featurerequest
Instead of just displaying the configured title (see now.jpg attached), display a textbox containing the title as default value (see new.jpg attached).
Then the shop admin could decide to leave the default title or set an individual one for that product.

Any other idea?

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3725
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to give a custom field a separate title for each product?
« Reply #9 on: December 10, 2020, 23:07:48 pm »
You know that You can change the order of customfields with drag and drop, yes ?

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

gba

  • Jr. Member
  • **
  • Posts: 329
Re: How to give a custom field a separate title for each product?
« Reply #10 on: December 11, 2020, 09:42:52 am »
Yes, I know and did that.
And it works in product view.
But in the cart the Y fields actually are not being rendered at the place, where they are in the product backend.
Also the setting 'Show Title' seems to be ignored: The title is rendered within the same span as the textaread content, right before it.
Seems to be a bit weird ...

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3491
  • VirtueMart Version: 3.8.9
Re: How to give a custom field a separate title for each product?
« Reply #11 on: December 11, 2020, 09:57:12 am »
You can always create your own customfield plugin if the core one does not suit your needs


And then you can create your own template to render as you want
Regards
A

Joomla 3.9.27
php 7.4

gba

  • Jr. Member
  • **
  • Posts: 329
Re: How to give a custom field a separate title for each product?
« Reply #12 on: December 11, 2020, 10:05:58 am »
I am using third party custom field plugins, which are constantly being maintained.
Everytime cloning them to have an editable title seems to be not that reasonable to me.

I attached the settings I made for the "title field" (see customfield.jpg).
I also attached a screenshot of the cart output, where I noted the order in the backend (see cart.jpg).

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10289
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to give a custom field a separate title for each product?
« Reply #13 on: December 11, 2020, 11:09:33 am »
how about

<span class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::_ ($field->custom_title.$product->virtuemart_product_id) ?></strong></span>

CUSTOMFIELD_TITLE22="title for pid 22"
CUSTOMFIELD_TITLE23="title for pid 23"

etc etc
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

gba

  • Jr. Member
  • **
  • Posts: 329
Re: How to give a custom field a separate title for each product?
« Reply #14 on: December 16, 2020, 18:30:24 pm »
Hi all!

Thank you again for your suggestions.

I gave the additional text field(s) before the concerning custom field(s) a try.
But it turned out, that it is not enough for us to just display an additional text field.
We need the title in the object of the respective custom field for further data processing.

The idea with concatenating the product id looks nice, too.
But actually we don't want to create a language override for every needed custom field in every product.

And cloning third party custom field plugins and maintaining the clones is way too expensive.

Therefore I am coming back to my idea:
The most flexible solution would be this new feature in the product backend, custom fields tab:
Instead of just displaying the configured title, display a textbox containing the title as default value.
Then the shop admin could decide to leave the default title or set an individual one for that product.

Unfortunately Milbo told me, that he is not interested in that feature.
From his point of view this would cost too much performance.
So does anyone, please, have any other/better idea to enable the shop admin to easily decide to leave the default custom field title or set an individual title for any product, where this is necessary?

I am very grateful for your help!

Kind regards,
Gerald