VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: Razva on September 27, 2011, 10:06:25 AM

Title: [SOLVED] Short description with WYSIWYG and HTML - possible?
Post by: Razva on September 27, 2011, 10:06:25 AM
Hi,

Please take a look at http://www.semineemures.ro/produse/accesorii/demo-1/Idro-50-1

As you can see, on the right side there's the short description, and under the image there's the "long description".

The problem is that the short description doesn't supports WYSIWYG or HTML.

We would like to insert formatted text/WYSIWYG  both in the description, which is ok right now, PLUS on the right side, where we have the short description right now.

Is there any way to activate formatted text/html/WYSIWYG for the short description? Or can we define a new field/secondary description? How can we accomplish that?

Thanks!
Title: Re: Second product description - possible?
Post by: Milbo on September 27, 2011, 15:01:58 PM
The short description does not allow to use html? I wonder, please try if you can add manually html code
Title: Re: Second product description - possible?
Post by: zarisko on September 27, 2011, 15:14:18 PM
You could also add the editor

http://www.joomlahackers.net/virtuemart-tutorials/adding-rich-text-and-images-to-the-short-description.html
Title: Re: Second product description - possible?
Post by: Razva on September 27, 2011, 16:44:05 PM
Quote from: Milbo on September 27, 2011, 15:01:58 PM
The short description does not allow to use html? I wonder, please try if you can add manually html code
I did, it doesn't...else I wouldn't opened this topic... :) Any HTML code is removed after saving the product.

Quote from: zarisko on September 27, 2011, 15:14:18 PM
You could also add the editor
That folder/file doesn't exists in V2. <?php echo $db->sf("product_s_desc"); ?> doesn't exists in any file...
Title: Re: Second product description - possible?
Post by: zarisko on September 27, 2011, 18:53:38 PM
sorry i didn't realise it was a VM2 topic.

but maybe the solution is the same, just different folder/file paths.
Title: Re: Second product description - possible?
Post by: PRO on September 27, 2011, 19:51:48 PM
administrator/components?com_virtuemart/views/product_edit_description.php

Change this
<textarea class="inputbox" name="product_s_desc" id="short_desc" cols="65" rows="3" ><?php echo $this->product->product_s_desc; ?></textarea>

To this
<?php echo $this->editor->display('product_s_desc',  $this->product->product_s_desc, '100%;', '550', '75', '20', array('pagebreak', 'readmore') ) ; ?>

then see what happens. The database field should allow it. BUT there might be a function stripping it.


JUST tested it, and it does strip the field of html.

Title: Re: Second product description - possible?
Post by: PRO on September 27, 2011, 20:03:38 PM
there is a function to allow html in product_desc
administrator/virtuemart/controllers  product.php


function save(){

      $product_desc = JRequest::getVar('product_desc','','post','STRING',JREQUEST_ALLOWRAW);
$data = JRequest::get('post');
$data['product_desc'] = $product_desc;
//       vmdebug('my data in product save ',$data);
      if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
      if(Permissions::getInstance()->check('admin')){
//          $data['product_desc'] = JRequest::getVar('product_desc','','post','STRING',JREQUEST_ALLOWHTML);
         $data['product_desc'] = JRequest::getVar('product_desc','','post','STRING',2);
      }

      parent::save($data);
   }

I believe you can use the same for product_s_desc
Title: Re: Second product description - possible?
Post by: Razva on September 27, 2011, 20:21:47 PM
Quote from: BanquetTables.pro on September 27, 2011, 19:51:48 PM
administrator/components?com_virtuemart/views/product_edit_description.php

Change this
<textarea class="inputbox" name="product_s_desc" id="short_desc" cols="65" rows="3" ><?php echo $this->product->product_s_desc; ?></textarea>

To this
<?php echo $this->editor->display('product_s_desc',  $this->product->product_s_desc, '100%;', '550', '75', '20', array('pagebreak', 'readmore') ) ; ?>

then see what happens. The database field should allow it. BUT there might be a function stripping it.
Yup, WYSIWYG appeared!

Quote from: BanquetTables.pro on September 27, 2011, 20:03:38 PM
there is a function to allow html in product_desc
administrator/virtuemart/controllers  product.php


function save(){

      $product_desc = JRequest::getVar('product_desc','','post','STRING',JREQUEST_ALLOWRAW);
$data = JRequest::get('post');
$data['product_desc'] = $product_desc;
//       vmdebug('my data in product save ',$data);
      if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
      if(Permissions::getInstance()->check('admin')){
//          $data['product_desc'] = JRequest::getVar('product_desc','','post','STRING',JREQUEST_ALLOWHTML);
         $data['product_desc'] = JRequest::getVar('product_desc','','post','STRING',2);
      }

      parent::save($data);
   }

I believe you can use the same for product_s_desc

Defined:

function save(){

      $product_s_desc = JRequest::getVar('product_s_desc','','post','STRING',JREQUEST_ALLOWRAW);
$data = JRequest::get('post');
$data['product_s_desc'] = $product_s_desc;
//       vmdebug('my data in product save ',$data);
      if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
      if(Permissions::getInstance()->check('admin')){
//          $data['product_s_desc'] = JRequest::getVar('product_s_desc','','post','STRING',JREQUEST_ALLOWHTML);
         $data['product_s_desc'] = JRequest::getVar('product_s_desc','','post','STRING',2);
      }

      parent::save($data);
   }


After saving the product I get
Fatal error: Cannot redeclare VirtuemartControllerProduct::save() in /home/semineem/public_html/administrator/components/com_virtuemart/controllers/product.php on line 124
when accesing Joomla Admin -> Virtuemart -> Products

How can I fix this please? Thanks a lot!
Title: Re: Second product description - possible?
Post by: PRO on September 27, 2011, 20:29:33 PM
edit, tried that and it still stripped

BUT: I believe this might be added to the core. I would wait for milbo to respond. Some users will want this.
Title: Re: Second product description - possible?
Post by: Razva on September 27, 2011, 20:33:29 PM
Defined "function save2()". Now the editor opens but, even if I just bold something, it doesn't saves (the modification disappears after Save).
Title: Re: Second product description - possible?
Post by: PRO on September 27, 2011, 20:36:24 PM
yes, I just tried it. I would wait for milbo to respond. He might wanna add this.
Title: Re: Second product description - possible?
Post by: Milbo on September 27, 2011, 23:21:29 PM
I add the right filter.
Title: Re: Second product description - possible?
Post by: Razva on September 27, 2011, 23:23:09 PM
Great! Thanks a lot! :)

Just please don't forget to tell us the name of the updated file/s.
Title: Re: Second product description - possible?
Post by: Milbo on September 27, 2011, 23:29:49 PM
it is only the controller
Title: Re: Second product description - possible?
Post by: Razva on September 27, 2011, 23:34:31 PM
I suppose that we're talking about
Quotehttps://dev.virtuemart.net/svn/virtuemart/trunk/virtuemart/administrator/components/com_virtuemart/controllers/product.php

NOTE: when replying this message the option didn't functioned, but I suppose we should wait till Milbo makes his magic :)
Title: Re: Second product description - possible?
Post by: Milbo on September 28, 2011, 11:09:04 AM
Yepp, this file, the save function should look like this

function save(){

$data = JRequest::get('post');

if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
if(Permissions::getInstance()->check('admin')){
$data['product_desc'] = JRequest::getVar('product_desc','','post','STRING',2);
$data['product_s_desc'] = JRequest::getVar('product_s_desc','','post','STRING',2);
}

parent::save($data);
}
Title: Re: Second product description - possible?
Post by: Razva on September 28, 2011, 11:33:06 AM
Hi Milbo,

Thanks for your time!

I've overwritten https://dev.virtuemart.net/svn/virtuemart/trunk/virtuemart/administrator/components/com_virtuemart/controllers/product.php but still...our VM installation doesn't saves any HTML. Should we disable the WYSIWYG and try to enter "raw" html?

Isn't there a way to keep the WYSIWYG + HTML?

Thanks!

LATER EDIT: IT WORKS!!! For posterity, you should replace the save() function from the default product.php with the function stated before by Milbo :)
Title: Re: [SOLVED] Short description with WYSIWYG and HTML - possible?
Post by: Aliciah85 on November 07, 2011, 06:30:22 AM
Hi Milbo- i have tried everything to get the product description to accept html to no avail. No matter what i do it strips the html and leaves just text.

I have changed the filtering permissions in the article options, i have checked that my JCE editor is set to not clean up code and i have downloaded and saved the newest product.php file (and then still overwritted the save function with the one you have stated above).

I have even copied the same save function used for category description as this is allowing html, but it did not change a thing!

i would appreciate any help you or any other users could give me!

thanks
Title: Re: [SOLVED] Short description with WYSIWYG and HTML - possible?
Post by: PRO on November 07, 2011, 15:10:18 PM
Aliciah85.   short DESCRIPTION? or FULL DESCRIPTION?

are you set to super admin? look in vmart /shoppers

Title: Re: [SOLVED] Short description with WYSIWYG and HTML - possible?
Post by: Aliciah85 on November 09, 2011, 03:42:44 AM
it was both. something i did fixed it, but i have no idea what :(
Title: Re: [SOLVED] Short description with WYSIWYG and HTML - possible?
Post by: man.of.earth on August 25, 2018, 11:34:03 AM
I found a simple solution. In /administrator/components/com_virtuemart/views/product/tmpl/product_edit_description.php:

Change

<textarea class="inputbox" name="product_s_desc" id="product_s_desc" cols="65" rows="3" ><?php echo $this->product->product_s_desc?></textarea>

for

<?php echo $this->editor->display('product_s_desc',  $this->product->product_s_desc'90%;''450''55''10', array('pagebreak''readmore') ) ; ?>

In order to keep this setting after VM updates, you may copy the modified file to
/administrator/templates/<backend_admin_template_folder>/html/com_virtuemart/product/product_edit_description.php

VirtueMart 3.2.14
Joomla 3.8.11
php 7.1
Title: Re: [SOLVED] Short description with WYSIWYG and HTML - possible?
Post by: razor7 on November 05, 2020, 18:08:08 PM
Quote from: arcturus on August 25, 2018, 11:34:03 AM
I found a simple solution. In /administrator/components/com_virtuemart/views/product/tmpl/product_edit_description.php:

Change

<textarea class="inputbox" name="product_s_desc" id="product_s_desc" cols="65" rows="3" ><?php echo $this->product->product_s_desc?></textarea>

for

<?php echo $this->editor->display('product_s_desc',  $this->product->product_s_desc'90%;''450''55''10', array('pagebreak''readmore') ) ; ?>

In order to keep this setting after VM updates, you may copy the modified file to
/administrator/templates/<backend_admin_template_folder>/html/com_virtuemart/product/product_edit_description.php

VirtueMart 3.2.14
Joomla 3.8.11
php 7.1

Cooool! it worked, thanks a lot!