J'avais envie d'avoir un slide image dans ma contrib Featured Products v2.3.x.
En me basant sur ceci : http://www.sohtanaka.com/web-design/automa...r-w-css-jquery/
J'ai utiliser une image particulière dans mon code " products_image_featured " pour obtenir une meilleure promotion du produit.
Donc voici ce que j'ai fait :
J'ai ajouté le code pour mon stylesheet via le lien (le tuto) sohtanaka ci-dessus.
et la modif du code de module/featured.php
Trouver (ligne 14 pour moi) :
Code
<?php if( defined('FEATURED_PRODUCTS_DISPLAY') AND FEATURED_PRODUCTS_DISPLAY == 'true' ) {
et insérer avant :
Code
<script type="text/javascript" src="[url="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"]http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>[/url]
Trouver (ligne 90 pour moi) :
Code
$num_featured_products = tep_db_num_rows($featured_products_query);
if ($num_featured_products > 0) {
$counter = 0;
$col = 0;
$featured_prods_content = '<table border="0" width="100%" cellspacing="0" cellpadding="2">';
while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$counter++;
if ($col === 0) {
$featured_prods_content .= '<tr>';
}
$featured_prods_content .= '<td width="33%" align="center" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br />' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</td>';
$col ++;
if (($col > 2) || ($counter == $num_featured_products)) {
$featured_prods_content .= '</tr>';
$col = 0;
}
}
$featured_prods_content .= '</table>';
?>
if ($num_featured_products > 0) {
$counter = 0;
$col = 0;
$featured_prods_content = '<table border="0" width="100%" cellspacing="0" cellpadding="2">';
while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$counter++;
if ($col === 0) {
$featured_prods_content .= '<tr>';
}
$featured_prods_content .= '<td width="33%" align="center" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br />' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</td>';
$col ++;
if (($col > 2) || ($counter == $num_featured_products)) {
$featured_prods_content .= '</tr>';
$col = 0;
}
}
$featured_prods_content .= '</table>';
?>
et remplacer par :
Code
$num_featured_products = tep_db_num_rows($featured_products_query);
?>
<div class="main_view">
<?php
if ($num_featured_products > 0) {
$counter = 0;
$num = 0;
$featured_prods_content = '<div class="window"><div class="image_reel">';
?>
<script>$(document).ready(function() {
//Show the paging and activate its first link
$(".paging").show();
$(".paging a:first").addClass("active");
//Get size of the image, how many images there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;
//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});
//Paging and Slider Function
rotate = function(){
var triggerID = $active.attr("rel") - 1; //Get number of times to slide
var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
$(".paging a").removeClass('active'); //Remove all active class
$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
//Slider Animation
$(".image_reel").animate({
left: -image_reelPosition
}, 500 );
};
//Rotation and Timing Event
rotateSwitch = function(){
play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
$active = $('.paging a.active').next(); //Move to the next paging
if ( $active.length === 0) { //If paging reaches the end...
$active = $('.paging a:first'); //go back to first
}
rotate(); //Trigger the paging and slider function
}, 7000); //Timer speed in milliseconds (7 seconds)
};
rotateSwitch(); //Run function on launch
//On Hover
$(".image_reel a").hover(function() {
clearInterval(play); //Stop the rotation
}, function() {
rotateSwitch(); //Resume rotation timer
});
//On Click
$(".paging a").click(function() {
$active = $(this); //Activate the clicked paging
//Reset Timer
clearInterval(play); //Stop the rotation
rotate(); //Trigger rotation immediately
rotateSwitch(); // Resume rotation timer
return false; //Prevent browser jump to link anchor
});
});</script>
<?php
while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$counter++;
$featured_prods_content .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image_featured'], $featured_products['products_name']) . '</a>';
}
if ($counter == 1) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a> </div></div>';
}
if ($counter == 2) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a> </div></div>';
}
if ($counter == 3) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a> </div></div>';
}
if ($counter == 4) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a><a href="#" rel="4">4</a> </div></div>';
}
if ($counter == 5) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a><a href="#" rel="4">4</a><a href="#" rel="5">5</a> </div></div>';
}
if ($counter == 6) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a><a href="#" rel="4">4</a><a href="#" rel="5">5</a><a href="#" rel="6">6</a> </div></div>';
}
}
?>
?>
<div class="main_view">
<?php
if ($num_featured_products > 0) {
$counter = 0;
$num = 0;
$featured_prods_content = '<div class="window"><div class="image_reel">';
?>
<script>$(document).ready(function() {
//Show the paging and activate its first link
$(".paging").show();
$(".paging a:first").addClass("active");
//Get size of the image, how many images there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;
//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});
//Paging and Slider Function
rotate = function(){
var triggerID = $active.attr("rel") - 1; //Get number of times to slide
var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
$(".paging a").removeClass('active'); //Remove all active class
$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
//Slider Animation
$(".image_reel").animate({
left: -image_reelPosition
}, 500 );
};
//Rotation and Timing Event
rotateSwitch = function(){
play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
$active = $('.paging a.active').next(); //Move to the next paging
if ( $active.length === 0) { //If paging reaches the end...
$active = $('.paging a:first'); //go back to first
}
rotate(); //Trigger the paging and slider function
}, 7000); //Timer speed in milliseconds (7 seconds)
};
rotateSwitch(); //Run function on launch
//On Hover
$(".image_reel a").hover(function() {
clearInterval(play); //Stop the rotation
}, function() {
rotateSwitch(); //Resume rotation timer
});
//On Click
$(".paging a").click(function() {
$active = $(this); //Activate the clicked paging
//Reset Timer
clearInterval(play); //Stop the rotation
rotate(); //Trigger rotation immediately
rotateSwitch(); // Resume rotation timer
return false; //Prevent browser jump to link anchor
});
});</script>
<?php
while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$counter++;
$featured_prods_content .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image_featured'], $featured_products['products_name']) . '</a>';
}
if ($counter == 1) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a> </div></div>';
}
if ($counter == 2) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a> </div></div>';
}
if ($counter == 3) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a> </div></div>';
}
if ($counter == 4) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a><a href="#" rel="4">4</a> </div></div>';
}
if ($counter == 5) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a><a href="#" rel="4">4</a><a href="#" rel="5">5</a> </div></div>';
}
if ($counter == 6) {
$featured_prods_content .= '</div><div class="paging"><a href="#" rel="1">1</a><a href="#" rel="2">2</a><a href="#" rel="3">3</a><a href="#" rel="4">4</a><a href="#" rel="5">5</a><a href="#" rel="6">6</a> </div></div>';
}
}
?>
Je pars sur le principe que 6 articles sont sélectionner pour l'affichage dans votre admin
Maintenant, j'aimerai trouver une autre solution que les if ($counter == x) pour le pagging
si les spécialistes du codage ont une solution, je suis preneur.
Merci