News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Allow GTIN or MPN field for HTML?

Started by Ferran, December 16, 2016, 15:42:11 PM

Previous topic - Next topic

Ferran

Is it posible? can someone help me?? Thanks!

Joomla 3.6
VM 3


jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

Ferran

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');
            }
         }

Studio 42

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.

PRO

what are you trying to accomplish?
formatting? run functions on the string?