Jump to content

how to move Stars Rating on homefeatured, solved!


Recommended Posts

hello

 

to <a> element add class="starsratings" like i show below:

<a class="starsratings" href="http://pieces4pc.com/es/musica-ipods/1-ipod-nano.html#idTab5"><div class="star star_on"></div><div class="star star_on"></div><div class="star star_on"></div><div class="star star_on"></div><div class="star star_on"></div>(1)</a>

then you can use in css styles:

 

.startsratings {padding-left:50px;}

Link to comment
Share on other sites

i followed instructions from this spanish post THIS, i modified

homefeatured.php

public function hookDisplayHome($params)
	{
		$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
			$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
			$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
			$link = new Link();
			foreach ($products as $p) {
				$query_sum = 'SELECT COUNT(*) as sum FROM '._DB_PREFIX_.'product_comment WHERE validate AND id_product = '.$p['id_product'];
				$sum_votes = Db::getInstance()->getValue($query_sum);
				
				$query_grades = 'SELECT SUM(grade) as grades FROM '._DB_PREFIX_.'product_comment WHERE validate AND id_product = '.$p['id_product'];
				$grades = Db::getInstance()->getValue($query_grades);
				
				if ($sum_votes > 0)
					$star = floor($grades / $sum_votes);
				else
					$star = 0;
		
				if ($star > 0) {
					$url_product = $link->getProductLink($p['id_product']).'#idTab5';
					$stars[$p['id_product']] .= '<a href="'.$url_product.'">';
					for ($i=1; $i<=5; $i++) {
						if ($star >= $i)
							$stars[$p['id_product']] .= '<div class="star star_on"></div>';
						else
							$stars[$p['id_product']] .= '<div class="star star_off"></div>';
					}
		
					$stars[$p['id_product']] .= '('.$sum_votes.')</a>';
				}
		
				
			}
				
		
			$this->smarty->assign(array(
					'products' => $products,
					'stars' => $stars,
					'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
					'homeSize' => Image::getSize('home_default'),
			));
		
			return $this->display(__FILE__, 'homefeatured.tpl');
	}

homefeatured.tpl

<div class="star_content">
    {if isset($stars[$product.id_product])} {$stars[$product.id_product]} {/if} 
</div>

product.tpl

<script type="text/javascript">
// <![CDATA[
$(document).ready(function()
{
	 if(window.location.hash === '#idTab5') {
		 $("#more_info_tabs").idTabs("idTab5");
	 }
});
            

productcomments.css

.star_content  div.star_on {background-position: 0 -12px }
Edited by haochen (see edit history)
Link to comment
Share on other sites

im using this on homefeatured.tpl

{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}

<!-- MODULE Home Featured Products -->
<div id="featured-products_block_center" class="block products_block clearfix">
	<p class="title_block">{l s='Featured products' mod='homefeatured'}</p>
	{if isset($products) AND $products}
		<div class="block_content">
			{assign var='liHeight' value=450}
			{assign var='nbItemsPerLine' value=3}
			{assign var='nbLi' value=$products|@count}
			{math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines}
			{math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight}
			<ul style="height:{$ulHeight}px;">
			{foreach from=$products item=product name=homeFeaturedProducts}
				{math equation="(total%perLine)" total=$smarty.foreach.homeFeaturedProducts.total perLine=$nbItemsPerLine assign=totModulo}
				{if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if}
				<li class="ajax_block_product {if $smarty.foreach.homeFeaturedProducts.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1} {/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - $totModulo)}last_line{/if}">
					
					<a href="{$product.link|escape:'html'}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, '210')}" alt="{$product.name|escape:html:'UTF-8'}" />{if isset($product.new) && $product.new == 1}<span class="new">{l s='New' mod='homefeatured'}</span>{/if}</a>
					<div class="star_content">
                        	{if isset($stars[$product.id_product])} {$stars[$product.id_product]} {/if}                       
					<div>
					<p class="s_title_block"><a href="{$product.link|escape:'html'}" title="{$product.name|truncate:50:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</a></p>
					
						{if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if}
						
						{if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE}
							{if ($product.quantity > 0 OR $product.allow_oosp)}
							<a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart')|escape:'html'}?qty=1&id_product={$product.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>
							{else}
							<span class="exclusive">{l s='Add to cart' mod='homefeatured'}</span>
							{/if}
						{else}
							<div style="height:23px;"></div>
						{/if}
					</div>
				</li>
			{/foreach}
			</ul>
		</div>
	{else}
		<p>{l s='No featured products' mod='homefeatured'}</p>
	{/if}
</div>

<!-- /MODULE Home Featured Products -->

Link to comment
Share on other sites

you forgot about div closing tag, take a look:

<div class="star_content">
{if isset($stars[$product.id_product])} {$stars[$product.id_product]} {/if}                       
<div>

and it should looks be:
 

<div class="star_content">
{if isset($stars[$product.id_product])} {$stars[$product.id_product]} {/if}                       
</div>
<div>
Link to comment
Share on other sites

ok, it was just one step :P

 

now open homefeatured.css

and change code from first line to:

#featured-products_block_center li {
margin-right: 15px;
padding: 10px 0;
width: 242px;
height: 290px;
}

now you can use in global.css something like:

.star_content{ margin-left:80px;}

effect:
lnEbN32.png

Link to comment
Share on other sites

×
×
  • Create New...