VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: reproteq on March 02, 2012, 12:25:48 PM

Title: VM 2.0.2 custom field allway display, not work only admin, public on-off not
Post by: reproteq on March 02, 2012, 12:25:48 PM
i make customs but allways display on , not work only admin see, i change but not respond.
i see change value  in db but allway displayed.

bug?
Title: Re: VM 2.0.2 custom field allway display, not work only admin, public on-off not
Post by: Milbo on March 02, 2012, 13:19:31 PM
yepp
Title: Re: VM 2.0.2 custom field allway display, not work only admin, public on-off not
Post by: reproteq on March 02, 2012, 14:07:10 PM
i place this

if ($field->display AND $this->product->customfieldsSorted['normal'][$field->virtuemart_custom_id]->admin_only=='0' ) {

now not see customer this fields.
but not good solution.

one can test whether a customfield toggles, is shown only for admin or always shown.
I think it's a bug or possibly when installing or modifying any file has stopped working.
but it seems strange that something as basic com will not work well.

the custom fields are always visible to everyone?
it works to publish or unpublish in vm 2.0.2 and joomla 2.5.1
Title: Re: VM 2.0.2 custom field allway display, not work only admin, public on-off not
Post by: reproteq on March 02, 2012, 17:41:23 PM
SOLUtion work 100%

comonents/com_virtuemart/views/podructdetails/tpl/default_customfields.php

<div class="product-fields">
       <?php
      
      $user =& JFactory::getUser();   // <--- recupera user
      
       $custom_title = null;
       foreach ($this->product->customfieldsSorted[$this->position] as $field) {

      //if ($field->display ) {
      if ($field->display AND ( $this->product->customfieldsSorted['normal'][$field->virtuemart_custom_id]->admin_only=='0' OR $user->get('isRoot') ) ) {    // checkea el tipo normal y solo muestra si es ROOT
          ?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
          <?php if ($field->custom_title != $custom_title) { ?>
             <span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
             <?php
             if ($field->custom_tip)
            echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
         }
         ?>
              <span class="product-field-display"><?php echo $field->display ?></span>
              <span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>
          </div>
          <?php
          $custom_title = $field->custom_title;
      }
       }
       ?>
        </div>

solution by salva gregori  info@undiez.es