Jump to content

[SOLVED] ALT in product image for block new products


namelesshachi

Recommended Posts

Hello!

i'm almost sure the answer is something really obvious, but i can't seem to make it work.

 

For SEO reasons i need the Block New Products to have alt in the images, it is declared in the tpl but when i check the code is empty

 

Here is the .tpl

<!-- MODULE Block new products -->
<section id="new-products_block_right" class="block products_block column_box">
	<h4 class="title_block"><span>{l s='New products' mod='blocknewproducts'}</span> <i class="column_icon_toggle icon-plus-sign"></i></h4>
	<div class="block_content toggle_content">
	{if $new_products !== false}
		<ul class="products">
		{foreach from=$new_products item=newproduct name=myLoop}
        	<li class="shop_box clearfix {if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
     
                	<a class="products_block_img" href="{$newproduct.link|escape:'html'}" title="{$product.name|escape:html:'UTF-8'} alt="{$product.name|escape:html:'UTF-8'}"><img src="{$link->getImageLink($newproduct.link_rewrite, $newproduct.id_image, 'medium_default')|escape:'html'}" alt="{$newproduct.name|escape:html:'UTF-8'}" /></a>
         
                <div >
            	<h5 class="s_title_block">
					<a class="product_link" href="{$newproduct.link|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'}">{$newproduct.name|strip_tags:'UTF-8'|truncate:22:'...'}</a>
            	</h5>
				{if $newproduct.description_short}
            		<p class="product_desc">{$newproduct.description_short|strip_tags:'UTF-8'|truncate:60:'...'}</p>
                    <a href="{$newproduct.link|escape:'html'}" class="lnk_more">{l s='Read more' mod='blocknewproducts'} <i class="icon-caret-right"></i></a>
            	{/if}
                </div>
            </li>
		{/foreach}
		</ul>
		<a href="{$link->getPageLink('new-products')|escape:'html'}" title="{l s='All new products' mod='blocknewproducts'}" class="btn btn-default button_large">{l s='All new products' mod='blocknewproducts'}</a>
	{else}
		<p>» {l s='Do not allow new products at this time.' mod='blocknewproducts'}</p>
	{/if}
	</div>
</section>
<!-- /MODULE Block new products -->

I see that the alt is alt="{$newproduct.name|escape:html:'UTF-8'}" but nothing is there when i run the website

 

using:

Prestashop 1.5.2.6

purchased template from Template Monster

website: www.reconocimientos.com

 

I appreciate any help!

Thank you!

Edited by namelesshachi (see edit history)
Link to comment
Share on other sites

First strange thing I see is an alt in your anchor tag:

<a class="products_block_img" href="{$newproduct.link|escape:'html'}" title="{$product.name|escape:html:'UTF-8'} alt="{$product.name|escape:html:'UTF-8'}">

 

2nd strange thing I see is a $product.name instead of $newproduct.name, which should give some warning in the final result (I don't see it on your shop page, so I assume you removed this already? If indeeed so, can you show the latest code you have now?)

 

All this has nothing to do directly with the image ALT code however, so maybe the following is the problem:

 

 

- is this the tpl from the themes/<your theme folder>/modules/blocknewproducts/blocknewproducts.tpl ? Did you make your changes there?

 

- Did you turn on force compile and turn off smarty caching for a moment when reloading the page? (Advanced Parameters->Optimization)

 

 

My 2 cents,

pascal.

Link to comment
Share on other sites

First strange thing I see is an alt in your anchor tag:

<a class="products_block_img" href="{$newproduct.link|escape:'html'}" title="{$product.name|escape:html:'UTF-8'} alt="{$product.name|escape:html:'UTF-8'}">

 

2nd strange thing I see is a $product.name instead of $newproduct.name, which should give some warning in the final result (I don't see it on your shop page, so I assume you removed this already? If indeeed so, can you show the latest code you have now?)

 

All this has nothing to do directly with the image ALT code however, so maybe the following is the problem:

 

 

- is this the tpl from the themes/<your theme folder>/modules/blocknewproducts/blocknewproducts.tpl ? Did you make your changes there?

 

- Did you turn on force compile and turn off smarty caching for a moment when reloading the page? (Advanced Parameters->Optimization)

 

 

My 2 cents,

pascal.

 

Hi Pascal!

First, thank you for the help

 

I did changed the  product.name to newproduct.name back
 
To make sure i was making the right changes, i  changed the tpl in the theme folder and the one in the module ofolder

 

This is my tpl in the module folder:

<!-- MODULE Block new products -->
<div id="new-products_block_right" class="block products_block">
	<h4 class="title_block"><a href="{$link->getPageLink('new-products')|escape:'html'}" title="{l s='New products' mod='blocknewproducts'}">{l s='New products' mod='blocknewproducts'}</a></h4>
	<div class="block_content">
	{if $new_products !== false}
		<ul class="product_images clearfix">
		{foreach from=$new_products item='product' name='newProducts'}
			{if $smarty.foreach.newProducts.index < 2}
				<li{if $smarty.foreach.newProducts.first} class="first"{/if}><a href="{$product.link|escape:'html'}"  title="{$newproduct.name|escape:html:'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'mediumdefault')|escape:'html'}" height="{$mediumSize.height}" width="{$mediumSize.width}"  title="{$newproduct.name|escape:html:'UTF-8'}"  alt="{$newproduct.name|escape:html:'UTF-8'}" /></a></li>
			{/if}
		{/foreach}
		</ul>
		<dl class="products">
		{foreach from=$new_products item=newproduct name=myLoop}
			<dt class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'}">{$newproduct.name|strip_tags|escape:html:'UTF-8'}</a></dt>
			{if $newproduct.description_short}<dd class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link|escape:'html'}">{$newproduct.description_short|strip_tags:'UTF-8'|truncate:26:'...'}</a><br /><a href="{$newproduct.link}" class="lnk_more">{l s='Read more' mod='blocknewproducts'}</a></dd>{/if}
		{/foreach}
		</dl>
		<p><a href="{$link->getPageLink('new-products')|escape:'html'}" title="{l s='All new products' mod='blocknewproducts'}" class="button_large">» {l s='All new products' mod='blocknewproducts'}</a></p>
	{else}
		<p>» {l s='Do not allow new products at this time.' mod='blocknewproducts'}</p>
	{/if}
	</div>
</div>
<!-- /MODULE Block new products -->

And the one in the theme folder:

<!-- MODULE Block new products -->
<section id="new-products_block_right" class="block products_block column_box">
	<h4 class="title_block"><span>{l s='New products' mod='blocknewproducts'}</span> <i class="column_icon_toggle icon-plus-sign"></i></h4>
	<div class="block_content toggle_content">
	{if $new_products !== false}
		<ul class="products">
		{foreach from=$new_products item=newproduct name=myLoop}
        	<li class="shop_box clearfix {if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
     
                	<a class="products_block_img" href="{$newproduct.link|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'}"><img src="{$link->getImageLink($newproduct.link_rewrite, $newproduct.id_image, 'mediumdefault')|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'} alt="{$newproduct.name|escape:html:'UTF-8'}" /></a>
         
                <div >
            	<h5 class="s_title_block">
					<a class="product_link" href="{$newproduct.link|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'}">{$newproduct.name|strip_tags:'UTF-8'|truncate:22:'...'}</a>
            	</h5>
				{if $newproduct.description_short}
            		<p class="product_desc">{$newproduct.description_short|strip_tags:'UTF-8'|truncate:60:'...'}</p>
                    <a href="{$newproduct.link|escape:'html'}" class="lnk_more">{l s='Read more' mod='blocknewproducts'} <i class="icon-caret-right"></i></a>
            	{/if}
                </div>
            </li>
		{/foreach}
		</ul>
		<a href="{$link->getPageLink('new-products')|escape:'html'}" title="{l s='All new products' mod='blocknewproducts'}" class="btn btn-default button_large">{l s='All new products' mod='blocknewproducts'}</a>
	{else}
		<p>» {l s='Do not allow new products at this time.' mod='blocknewproducts'}</p>
	{/if}
	</div>
</section>
<!-- /MODULE Block new products -->
Link to comment
Share on other sites

Ah, I think I see it now.

 

(We are talking about the file in the theme folder, as this one is overriding the module folder one. In other words, the file in the theme folder is the one really used):

 

You have this piece of code here:

 

<a class="products_block_img" href="{$newproduct.link|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'}"><img src="{$link->getImageLink($newproduct.link_rewrite, $newproduct.id_image, 'mediumdefault')|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'} alt="{$newproduct.name|escape:html:'UTF-8'}" /></a>

 

 

As you can see, the title of the <img tag has an opening " but NO closing ". (The opening " of the alt is used as closing " for the title):

 

I think if you add the closing " for the title, it should work:

title="{$newproduct.name|escape:html:'UTF-8'}" <--add this "

alt="{$newproduct.name|escape:html:'UTF-8'}"

                                   

                                   

 

Give it a try,

pascal.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...