StewartF Posted October 15, 2014 Share Posted October 15, 2014 Morning Just a quick question this morning about the New Products module 1. Is it possible to display it horizontally I want it to go beneath Nav or beneath Top Menu or slider. So need it to be able to be tranplantable into those hooks 2. Is it possible to randomise new products showing like you can do for home page featured Thanks Stewart Link to comment Share on other sites More sharing options...
NemoPS Posted October 15, 2014 Share Posted October 15, 2014 The first one is easy, just clone hookDisplayRightColumn (or left) and rename it to hookDisplayTop to support the new position. As for the other is a bit more complicated. Depending on your ps version, have a look at Product::getNewProducts, around line 2101 of product.ph (classes). There is an order by $sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way)); Link to comment Share on other sites More sharing options...
StewartF Posted October 16, 2014 Author Share Posted October 16, 2014 Okay thanks for that but how do you clone the hook? What do you do to that script to make new products random? I am using 1.6.09 Stewart Link to comment Share on other sites More sharing options...
NemoPS Posted October 17, 2014 Share Posted October 17, 2014 To close simply copy/paste the same and rename it to hookDisplayTop as I said As for the script try changing it to ORDER BY RAND() Link to comment Share on other sites More sharing options...
StewartF Posted October 17, 2014 Author Share Posted October 17, 2014 To close simply copy/paste the same and rename it to hookDisplayTop as I said As for the script try changing it to ORDER BY RAND() Okay second bit is no problem. I can find and do that. The first part is still confused to me (Sorry). Where am I copying hook from ? Is this done in phpadmin? Or in site files? There is already a displayTop. Am I creating complete new hook then? Won't I need to do some extra work in Controller and homepage template? I ask this as I have read this and not sure if relevant? Apologies. I have some programming and design knowledge but not necessarily enough by looks of it Stewat Link to comment Share on other sites More sharing options...
vekia Posted October 17, 2014 Share Posted October 17, 2014 you have to alter module file, not database etc. blocknewproducts.php located in module directory /modules/blocknewproducts/ Link to comment Share on other sites More sharing options...
StewartF Posted October 21, 2014 Author Share Posted October 21, 2014 you have to alter module file, not database etc. blocknewproducts.php located in module directory /modules/blocknewproducts/ Okay so I have this: public function install() { $success = (parent::install() && $this->registerHook('header') && $this->registerHook('addproduct') && $this->registerHook('updateproduct') && $this->registerHook('deleteproduct') && Configuration::updateValue('NEW_PRODUCTS_NBR', 5) && $this->registerHook('displayHomeTab') && $this->registerHook('displayHomeTabContent') ); Do I just add: && $this->registerHook('displayTop') onto the bottom then? Because you also have : if ($success) { // Hook the module either on the left or right column $theme = new Theme(Context::getContext()->shop->id_theme); if ((!$theme->default_left_column || !$this->registerHook('leftColumn')) && (!$theme->default_right_column || !$this->registerHook('rightColumn'))) { // If there are no colums implemented by the template, throw an error and uninstall the module $this->_errors[] = $this->l('This module need to be hooked in a column and your theme does not implement one'); parent::uninstall(); return false; } } Which looks like more conditional positional instructions. Does this need amending too? Stewart Link to comment Share on other sites More sharing options...
NemoPS Posted October 22, 2014 Share Posted October 22, 2014 Add the registerhook, then find hookDisplayHomeTabContent, copy the whole method, and change the name to hookDIsplayTop, then where it returns the tpl at the end, change the tpl name to another and create that file. THis way you can have 2 separate templates Link to comment Share on other sites More sharing options...
StewartF Posted October 22, 2014 Author Share Posted October 22, 2014 Add the registerhook, then find hookDisplayHomeTabContent, copy the whole method, and change the name to hookDIsplayTop, then where it returns the tpl at the end, change the tpl name to another and create that file. THis way you can have 2 separate templates Okay so this is here I'm at thanks to your patience guys: blocknewproducts.php: 1st change public function install() { $success = (parent::install() && $this->registerHook('header') && $this->registerHook('addproduct') && $this->registerHook('updateproduct') && $this->registerHook('deleteproduct') && Configuration::updateValue('NEW_PRODUCTS_NBR', 5) && $this->registerHook('displayHomeTab') && $this->registerHook('displayHomeTabContent') && $this->registerHook('displayTop') ); 2nd change further down: public function hookdisplayTop($params) { if (!$this->isCached('blocknewproducts_top.tpl', $this->getCacheId('blocknewproducts-home'))) { $this->smarty->assign(array( 'new_products' => BlockNewProducts::$cache_new_products, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')) )); } if (BlockNewProducts::$cache_new_products === false) return false; return $this->display(__FILE__, 'blocknewproducts_top.tpl', $this->getCacheId('blocknewproducts-home')); } And copying blocknewproducts.tpl copying it and renaming blocknewproducts_top.tpl Problem is though that nothing appears and stuff is in odd places - see screenshot attached Link to comment Share on other sites More sharing options...
StewartF Posted October 22, 2014 Author Share Posted October 22, 2014 Right an improvement. Duplicate hook should be: public function hookdisplayTop($params) { if (!$this->isCached('blocknewproducts_top.tpl', $this->getCacheId('blocknewproducts'))) { $this->smarty->assign(array( 'new_products' => BlockNewProducts::$cache_new_products, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')) )); } if (BlockNewProducts::$cache_new_products === false) return false; return $this->display(__FILE__, 'blocknewproducts_top.tpl', $this->getCacheId('blocknewproducts')); But as I thought every thing is vertically in a tower rather than horizontally with descriptions etc underneath the images. Stew Link to comment Share on other sites More sharing options...
NemoPS Posted October 24, 2014 Share Posted October 24, 2014 Remove all cache references for now public function hookdisplayTop($params) { $this->smarty->assign(array( 'new_products' => $this->getNewProducts(), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')) )); return $this->display(__FILE__, 'blocknewproducts_top.tpl'); Link to comment Share on other sites More sharing options...
StewartF Posted November 3, 2014 Author Share Posted November 3, 2014 Sorry I have been away for a while. That doesn't fix it. Screen shot attached. Will I need to change the CSS as obviously it is designed as a right block? Stew Link to comment Share on other sites More sharing options...
NemoPS Posted November 5, 2014 Share Posted November 5, 2014 I can't remember just now if it references columns in the css definition. But yeah, you need to style it in any case Link to comment Share on other sites More sharing options...
Recommended Posts