VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: VMRESLO on March 21, 2015, 08:52:06 AM

Title: Configuring specific custom field
Post by: VMRESLO on March 21, 2015, 08:52:06 AM
Hello evereybody!

I have created a string custom field Age and when I write in the box (in the products tab) "55" I would like it to be written at the frontend as "55 years". I think I could achieve this by adding something like <echo "years"> to the php file at the end of this specific custom field, but I can not find the php file that contains all of my custom fields.
I know that the simplest solution would be just to write "55 years" in the custom field box, but I have a lot of similar custom fields and this sort of automatization would be really helpful.

I am using VirtueMart 3.0.6.2 on joomla 3.4.

Any help would be very appreciated. I would also be very grateful if anybody has any other ideas how to achieve the same effect.

Best regards!
Title: Re: Configuring specific custom field
Post by: PRO on March 21, 2015, 17:29:30 PM
This might help:


http://forum.virtuemart.net/index.php?topic=128936.0

Title: Re: Configuring specific custom field
Post by: VMRESLO on March 22, 2015, 10:36:44 AM
Thank you for replying but unfortunately this way doesn't seem to work.

All my string custom fields are automatically classed into "product-field product-field-type-S" and I don't want them all to end with "years".  I would like to add "years" only to the custom field titled "Age".

Still when I tryed this code I didn't seem to work and resulted in a blank screen. What did I do wrong?

<?php
/**
* sublayout products
*
* @package VirtueMart
* @author Max Milbers
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2014 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL2, see LICENSE.php
* @version $Id: cart.php 7682 2014-02-26 17:07:20Z Milbo $
*/

defined('_JEXEC') or die('Restricted access');

$product $viewData['product'];
$position $viewData['position'];
$customTitle = isset($viewData['customTitle'])? $viewData['customTitle']: false;;
if(isset(
$viewData['class'])){
$class $viewData['class'];
} else {
$class 'product-fields';
}

if (!empty(
$product->customfieldsSorted[$position])) {
if ($class !='product-field product-field-type-S' ){
?>

<div class="<?php echo $class?>">
<?php
if($customTitle and isset($product->customfieldsSorted[$position][0])){
$field $product->customfieldsSorted[$position][0]; ?>

<div class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::($field->custom_title?></strong></span>
<?php if ($field->custom_tip) {
echo JHtml::tooltip (vmText::_($field->custom_tip), vmText::($field->custom_title), 'tooltip.png');
?>

</div> <?php
}
$custom_title null;
foreach ($product->customfieldsSorted[$position] as $field) {
if ( $field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
?>
<div class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if (!$customTitle and $field->custom_title != $custom_title and $field->show_title) { ?>
<span class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::($field->custom_title?></strong></span>
<?php if ($field->custom_tip) {
echo JHtml::tooltip (vmText::_($field->custom_tip), vmText::($field->custom_title), 'tooltip.png');
?>
</span>
<?php }
if (!empty($field->display)){
?>
<div class="product-field-display"><?php echo $field->display ?></div><?php
}
if (!empty($field->custom_desc)){
?>
<div class="product-field-desc"><?php echo vmText::_($field->custom_desc?></div> <?php
}
?>

</div>
<?php
$custom_title $field->custom_title;
?>

      <div class="clear"></div>
</div>
<?php
} }?>


<?php
if ($class=='product-field product-field-type-S' && $product->customfieldsSorted[$position]) {
   
?>

   <div class="<?php echo $class?>">
      <?php
      
if($customTitle and isset($product->customfieldsSorted[$position][0])){
         
$field $product->customfieldsSorted[$position][0]; ?>

      <div class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::($field->custom_title?></strong></span>
         <?php if ($field->custom_tip) {
            echo 
JHtml::tooltip (vmText::_($field->custom_tip), vmText::($field->custom_title), 'tooltip.png');
         } 
?>

      </div> <?php
      
}
      
$custom_title null;
      foreach (
$product->customfieldsSorted[$position] as $field) {
         if ( 
$field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
         
continue;
         
?>
<div class="product-field product-field-type-<?php echo $field->field_type ?>">
            <?php if (!$customTitle and $field->custom_title != $custom_title and $field->show_title) { ?>
               <span class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::($field->custom_title?></strong></span>
                  <?php if ($field->custom_tip) {
                     echo 
JHtml::tooltip (vmText::_($field->custom_tip), vmText::($field->custom_title), 'tooltip.png');
                  } 
?>
</span>
            <?php }
            if (!empty(
$field->display)){
               
?>
<div class="product-field-display"><?php echo $field->display ?></div><?php
            
}
            if (!empty(
$field->custom_desc)){
               
?>
<div class="product-field-desc"><?php echo vmText::_($field->custom_desc?> <?php echo "years"?> </div> <?php
            
}
            
?>

         </div>
      <?php
         $custom_title 
$field->custom_title;
      } 
?>

      <div class="clear"></div>
   </div>
<?php
} }?>


Thank you in advance!
Title: Re: Configuring specific custom field
Post by: PRO on March 22, 2015, 15:18:33 PM

try

'years'