VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: divined on June 27, 2017, 07:37:32 AM

Title: Display an HTML link in short description
Post by: divined on June 27, 2017, 07:37:32 AM
Hello everybody

Is it possible to enter a link into the product short description using HTML code and an image. I would like for example to add <a href="url"><img src="images\apic.png"></a>.

I tried to do that but nothing appeared in the category layout of the products. Am I missing something here?
Title: Re: Display an HTML link in short description
Post by: hellorain on June 27, 2017, 13:10:10 PM
Hello,

Below is syntax.

<a href="url"><img src="images/apic.png"></a>.

Best Regards,
hellorain.
Title: Re: Display an HTML link in short description
Post by: PRO on June 27, 2017, 17:47:15 PM
you can easily use a custom field type "editor"

Title: Re: Display an HTML link in short description
Post by: divined on June 27, 2017, 20:31:27 PM
Thank you both for the reply!

As to embedding HTML into the short description, I've already tried that. Unfortunately, it simply doesn't appear. Maybe it has something to do with the CSS category product layout?

As for the custom fields editor, is there some recommendation you can make? I've experimented with custom fields but they require some php tinkering and I'm not exactly sure what to change.
Title: Re: Display an HTML link in short description
Post by: Jörgen on June 27, 2017, 21:30:44 PM
Hello
Have You noticed that hellorain corrected your link ? If the file exists at that URL you will see it in the description. Check and see if you have strip_tags or something similar that is used when displaying. With protostar this should work. What do You get? A broken link image?

regards

Jörgen @ Kreativ Fotografi
Title: Re: Display an HTML link in short description
Post by: amedesign on June 27, 2017, 22:28:06 PM
Quote from: divined on June 27, 2017, 07:37:32 AM
Hello everybody

Is it possible to enter a link into the product short description using HTML code and an image. I would like for example to add <a href="url"><img src="images\apic.png"></a>.

I tried to do that but nothing appeared in the category layout of the products. Am I missing something here?


You have the corrected syntax by hellorain. It should work.

As a general advice, I am using a dedicated article (not published) for editing content, for putting in different places (description for products, categories, even in plugins description text) and apply style as I wish on the text. Then go to code tab and copy the html syntax, then paste where it need. In this way I have in the same place all the text, view instant the results and I am sure that the syntax is correct every time.
Title: Re: Display an HTML link in short description
Post by: divined on June 27, 2017, 23:06:00 PM
I checked my site's code using Firebug and didn't find the link anywhere in the <product_sdesc> division of the specific product. This is the URL of my site: http://www.gpb.gr/index.php/2017-05-07-15-17-06/photocopiers/b-w-photocopiers

I've added the code given by hellorain to the last product of the page given above. In the backend I have the product_sdesc: <a href="url"><img src="images/other/adobe_s.png"></a><br>Αύτόματη διπλή όψη<br>Ταχύτητα 20 άντ/λεπτό<br>Μέγεθος χαρτιού Α4<br>Διαστάσεις Φ518xB445xH298 mm<br>ΦΑΞ προαιρετικό<br>

On the division of relevant product I only get the code:  Αύτόματη διπλή όψη<br>Ταχύτητα 20 άντ/λεπτό<br>Μέγεθος χαρτιού Α4<br>Διαστάσεις Φ518xB445xH298 mm<br>ΦΑΞ προαιρετικό                                 

which means that the HTML anchor code is being filtered somewhere along the way.

Sorry for the Greek!
Title: Re: Display an HTML link in short description
Post by: Jörgen on June 28, 2017, 00:31:45 AM
Have You tested with another template? Check the sublayout products.php to see what gives, around line 109 you should find the output. I use Hera from Olympian themes and it works with the link.

Jörgen @ Kreativ Fotografi
Title: Re: Display an HTML link in short description
Post by: divined on June 30, 2017, 07:29:23 AM
I'm still using the vmbeez3 template. Theoretically it should be able to render the HTML code. This is the code of the sublayout products.php:

<p class="product_s_desc">
      <?php // Product Short Description
      if (!empty($product->product_s_desc)) {
         echo shopFunctionsF::limitStringByWord ($product->product_s_desc, 400, ' ...') ?>
      <?php } ?>
</p>


Might the limitStringByWord function be omitting the relevant HTML code?
Title: Re: Display an HTML link in short description
Post by: Jörgen on June 30, 2017, 07:49:47 AM
Hello in my case this works. But I have an older VM version 3.0.19

Try this:
<p class="product_s_desc">
      <?php // Product Short Description
      
if (!empty($product->product_s_desc)) {
         
//echo shopFunctionsF::limitStringByWord ($product->product_s_desc, 400, ' ...')?>

         echo $product->product_s_desc; ?>
      <?php ?>
</p>

This will show if shopFunctionsF::limitStringByWord() strips the output  ;)

Jörgen @ Kreativ Fotografi
Title: Re: Display an HTML link in short description
Post by: divined on June 30, 2017, 23:15:26 PM
Thank you for the reply

I found the cause of the problem. Once again it had to do with not setting up the multilingual properties correctly. After setting up my virtuemart according to the instructions given in this page: https://docs.virtuemart.net/tutorials/multilingual-store/99-multilanguage-setup.html everything worked correctly.