VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Ferran on December 16, 2016, 15:42:11 PM

Title: Allow GTIN or MPN field for HTML?
Post by: Ferran on December 16, 2016, 15:42:11 PM
Is it posible? can someone help me?? Thanks!

Joomla 3.6
VM 3

Title: Re: Allow GTIN or MPN field for HTML?
Post by: jenkinhill on December 16, 2016, 16:12:19 PM
Please explain better what you want to do.  http://forum.virtuemart.net/index.php?topic=104795.0
Title: Re: Allow GTIN or MPN field for HTML?
Post by: Ferran on December 16, 2016, 16:24:28 PM
I wanted to allow HTML in the GTIN field, finally i edited the save function in controller and it works. Sorry for my english :)

function save($data = 0){

      if($data===0)$data = vRequest::getRequest();

      $user = JFactory::getUser();
      if($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart') or $user->authorise('vm.raw','com_virtuemart')){
         $data['product_desc'] = vRequest::get('product_desc','');
         $data['product_s_desc'] = vRequest::get('product_s_desc','');
         $data['customtitle'] = vRequest::get('customtitle','');
                        $data['product_gtin'] = vRequest::get('product_gtin','');

         if(isset($data['field'])){
            $data['field'] = vRequest::get('field');
         }

         if(isset($data['childs'])){
            foreach($data['childs'] as $k=>$v){
               if($n = vRequest::get('product_name',false,FILTER_UNSAFE_RAW,FILTER_FLAG_NO_ENCODE,$data['childs'][$k])){
                  $data['childs'][$k]['product_name'] = $n;
               }
            }
         }

      } else  {
         if($user->authorise('vm.html','com_virtuemart')){
            $data['product_desc'] = vRequest::getHtml('product_desc','');
            $data['product_s_desc'] = vRequest::getHtml('product_s_desc','');
            $data['customtitle'] = vRequest::getHtml('customtitle','');
                                $data['product_gtin'] = vRequest::getHtml('product_gtin','');

            if(isset($data['field'])){
               $data['field'] = vRequest::getHtml('field');
            }
         } else {
            $data['product_desc'] = vRequest::getString('product_desc','');
            $data['product_s_desc'] = vRequest::getString('product_s_desc','');
            $data['customtitle'] = vRequest::getString('customtitle','');
                                $data['product_gtin'] = vRequest::getString('product_gtin','');

            if(isset($data['field'])){
               $data['field'] = vRequest::getString('field');
            }
         }
Title: Re: Allow GTIN or MPN field for HTML?
Post by: Studio 42 on December 16, 2016, 18:51:06 PM
First, this is bad, secondly, you can certainly use a template overide and changes the code in front.
Suppose a day you need to change the HTML? You have tp modify all your gtin.
If you need to change some render, i think it's the badest way to do and this can be done with customfields directly and not use the gtin.
Title: Re: Allow GTIN or MPN field for HTML?
Post by: PRO on December 16, 2016, 21:26:12 PM
what are you trying to accomplish?
formatting? run functions on the string?