News:

Support the VirtueMart project and become a member

Main Menu

Display an HTML link in short description

Started by divined, June 27, 2017, 07:37:32 AM

Previous topic - Next topic

divined

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?

hellorain

Hello,

Below is syntax.

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

Best Regards,
hellorain.
Raincreatives - Virtuemart & Mobile Commerce Experts

PRO

you can easily use a custom field type "editor"


divined

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.

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

amedesign

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.

divined

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!

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

divined

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?

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

divined

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.