Jump to content

Obligé de "refresh" la page pour que les scripts de ma page marche


Macjo

Recommended Posts

Bonjour,

 

Depuis ce matin, j'ai un nouveau problème :/

J'ai créé quelques lignes de script dans la page "product-list.tpl" pour pouvoir récupérer la largeur de mes images. (pas celles des miniatures car mes images sont redimenssionées par la hauteur).

 

La page fonctionne... mais pas toujours.

Je suis souvent obligé de rafrâichir la page en question pour que mes scripts se lancent :/

 

Le code en question :

 

<script type="text/javascript">
//<![CDATA[
var i=0;
//]]>
</script>

{if isset($products)}
<!-- Products list -->
<ul id="product_list" class="clear">
{foreach from=$products item=product name=products}
<script type="text/javascript">
//<![CDATA[
document.write('<img style="display:none" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'gallery')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}"');
document.write('id="imgg-');
document.write(i);
document.write('"');
document.write('/>');
var idimg="imgg-"+i;
document.write('<li class="ajax_block_product {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix"style="width:');
document.write(document.getElementById(idimg).width);
document.write('px;">');
//]]>
</script>

  <div class="center_block">
<script type="text/javascript">
//<![CDATA[
document.write('<div style="width:');
document.write(document.getElementById(idimg).width);
document.write('px; overflow:hidden;height:310px; padding:0; position:relative;">');
//]]>
</script>

<a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}">
<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'gallery')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />
</a>
<script type="text/javascript">
//<![CDATA[

document.write('<div style="width:');
document.write(document.getElementById(idimg).width);
document.write('px;" class="infos-prod-list">');
i++;
//]]>
</script>
 <h3><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</a>{if isset($product.new) && $product.new == 1}<span class="new-prod">{l s='New'}</span>{/if}</h3>
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span>{/if}{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}
  {if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
 {if ($product.allow_oosp || $product.quantity > 0)}
  <a class="add-to-card-list" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart.php')}?add&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>
 {else}
   <span class="add-to-card-list-exclusive">{l s='Add to cart'}</span>
 {/if}
{/if}
 </div>
</div>

Problème résolu avec PHP

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...