Jump to content

new product template.. help


Recommended Posts

hi,

is there anyone could kindly help me on this?

i would like the new product page to look like home featured page.. ( i.e. there is "view" button , the "availability" to be "out of stock" if possible ) when the product is out of stock...and the "add to cart" button remain the same

thanks!

17449_KQSRXqzrMYmgDr14pQQf_t

Link to comment
Share on other sites

Open your modules/blocknewproducts/blocknewproducts.php file and find this bit:

    function hookRightColumn($params)
   {
       global $smarty;
       $currency = new Currency(intval($params['cookie']->id_currency));
       $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR'));
       $new_products = array();
       if ($newProducts)
           foreach ($newProducts AS $newProduct)
               $new_products[] = $newProduct;

       $smarty->assign(array(
           'new_products' => $new_products,
           'mediumSize' => Image::getSize('medium')));
       return $this->display(__FILE__, 'blocknewproducts.tpl');
   }

   function hookLeftColumn($params)
   {
       return $this->hookRightColumn($params);
   }


Replace it with this code:

function prepareProductsArray($params) {
   global $smarty;
   $currency = new Currency(intval($params['cookie']->id_currency));
   $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR'));
   $new_products = array();
   if ($newProducts) {
       foreach ($newProducts AS $newProduct) {
           $new_products[] = $newProduct;
       }
   }
   $smarty->assign(array('new_products' => $new_products, 'mediumSize' => Image::getSize('medium')));
}

function hookRightColumn($params) {
   $this->prepareProductsArray($params);
   return $this->display(__FILE__, 'blocknewproducts.tpl');
}

function hookLeftColumn($params) {
   return $this->hookRightColumn($params);
}

function hookHome($params) {
   $this->prepareProductsArray($params);
   return $this->display(__FILE__, 'blocknewproducts_center.tpl');
}


Now create a new file called blocknewproducts_center.tpl in modules/blocknewproducts:

<!-- MODULE Block new products in center column -->

{l s='New products' mod='blocknewproducts'}

   {if $new_products|@count > 0}
       {assign var='liHeight' value=360}
       {assign var='nbItemsPerLine' value=4}
       {assign var='nbLi' value=$new_products|@count}
       {assign var='nbLines' value=$nbLi/$nbItemsPerLine|ceil}
       {assign var='ulHeight' value=$nbLines*$liHeight}

       {foreach from=$new_products item=newproduct name=myLoop}

{$newproduct.name|strip_tags|escape:htmlall:'UTF-8'}

{t text=$newproduct.description_short length='50' strip='true' encode='true'}

getImageLink($newproduct.link_rewrite, $newproduct.id_image, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$new_products.legend|escape:htmlall:'UTF-8'}" />

                       {if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$newproduct.price}{if $priceDisplay == 2} {l s='+Tx' mod='blocknewproducts'}{/if}{/if}
                       {if $priceDisplay}
{convertPrice price=$newproduct.price_tax_exc}{if $priceDisplay == 2} {l s='-Tx' mod='blocknewproducts'}{/if}{/if}
{l s='View' mod='blocknewproducts'}
                       {if ($newproduct.quantity > 0 OR $newproduct.allow_oosp) AND $newproduct.customizable != 2}
{l s='Add to cart' mod='blocknewproducts'}
                       {else}
{l s='Add to cart' mod='blocknewproducts'}
                       {/if}


       {/foreach}

{l s='All new products' mod='blocknewproducts'}
   {else}

{l s='No new product at this time' mod='blocknewproducts'}
   {/if}


<!-- /MODULE Block new products -->


And you're done.
You can now transplant this module to Homepage content hook and it will display the way Featured products do.
You shouldn't need any css changes, since it already has all the necessary rules (search "/* Special style for block products in center column */" line in your global.css file)
George.

Link to comment
Share on other sites

Hi George,

Thanks for your kind help.. but it still the same.. when i transplant the module to homepage content.. new product page mix up with the homefeatured page.. but the view button didn't show up..

>_

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