News:

Support the VirtueMart project and become a member

Main Menu

Custom fields layout - wrap in parent and add class?

Started by JyTy, August 10, 2012, 09:23:49 AM

Previous topic - Next topic

JyTy

Hi,

I have a question about custom fields, right now their html gets generated like this:

<div class="product-field product-field-type-P"></div>
<div class="product-field product-field-type-S"></div>
<div class="product-field product-field-type-S"></div>
<div class="product-field product-field-type-S"></div>
<div class="product-field product-field-type-S"></div>

Is there a way to modify default_customfields.php so that custom fields that have a parent are wrapped in it (I would also like to add parent a unique class like its name)? Like this:

<div class="product-field product-field-type-P tv-specs">
    <div class="product-field product-field-type-S"></div>
    <div class="product-field product-field-type-S"></div>
    <div class="product-field product-field-type-S"></div>
    <div class="product-field product-field-type-S"></div>
</div>

I need this to solve the multilanguage problem of creating custom fields for more languages. I would create one group for each language and then hide them with css based on the language selected on the site.
Or has anyone came up with a better solution (I need to translate values too not just the field names, I have found a solution on the forum for that)

Thank you for all your help, really appreciated!
Have a nice day  8)

Rocked

#1
Hey I was looking for the same thing! :)  Figured out an answer so thought I'd share...  it's not perfect but it worked for me!  I never put descriptions under custom fields... so I am just using the descriptions box basically as my added class name -- all you have to do is type in "tv-specs" under description on the custom field and it will now add the class.

First... create a folder in your template directory like this (TEMPLATE NAME)/html/com_virtuemart/productdetails.  Then copy and paste the default_customfields.php over into it.  (You could just write over the original, but I prefer using overrides whenever possible.)

Next replace:

    <div class="product-field product-field-type-<?php echo $field->field_type ?>">
<span class="product-fields-title" ><b><?php echo JText::_($field->custom_title?></b></span>
<?php if ($field->custom_tip)
    echo JHTML::tooltip($field->custom_tipJText::_($field->custom_title), 'tooltip.png'); ?>

<br/>
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
    </div><br />
    <?php

With:

<div class="product-field product-field-type-<?php echo $field->field_type; if (!empty($field->custom_field_desc)) {
  echo  " "; echo $field->custom_field_desc;}?>
">
<span class="product-fields-title" ><b><?php echo JText::_($field->custom_title?></b></span>
<?php if ($field->custom_tip)
    echo JHTML::tooltip($field->custom_tipJText::_($field->custom_title), 'tooltip.png'); ?>

<br/>
<span class="product-field-display"><?php echo $field->display ?></span>
    </div><br />



Basically just echoed in the description as the class name & took the span displaying the description out ... & that's it!

(note if you bought a template -- like me... the template maker may have ignored the standard setup and the custom field code you are looking for might just be in default.php insteed of default_customfields.php)
ROCKED LLC - Business Class Web Solutions
RockedStudios.com RockedMarketing.com RockedHosting.com  (Coming Soon) 

Customized VM Setup, Development, Hosting & Design

JyTy

Thank you for posting Rocked!
I think your approach should work for me just fine too  8)

Rocked

No problem... I'd really like to see an extra input when editing custom fields with something like "Add Class" or something in the core.  It would be really handy! 
ROCKED LLC - Business Class Web Solutions
RockedStudios.com RockedMarketing.com RockedHosting.com  (Coming Soon) 

Customized VM Setup, Development, Hosting & Design

be

Hi,
thanks, for something like this I have looked forward a lot of time.
I would also appreciate a own field for css-class or/and id.

Best regard