Jump to content

Moving Left/Right native blocks to home page content


Recommended Posts

Yeah, it's me again... but trust me, once i'm done with this i'll be a certified junior on Prestashop Theming and will lend a hand to newbies too :D

Anyway... it seems that it is quite difficult for the Prestashop's administrator to move blocks around from hooks they, i guess, were designed for... eg: when i try to move the "BEST SELLERS" block from the left/right blocks to the home page content, it utterly fails. Sometimes it just doesn't show, sometimes it goes on showing on the side hooks, or it even causes some mayhem on my page... like it is doing now: example.

As you can see, even though in my administrator the module is assigned to home page content (at the end of it, same result if i move it up or down anyway) in the homepage you can see that not only it is assigned to the right column but is also cut in half, the top part of it even showing on top of the page.

Maybe this is an inherited issue from having moved the search block around, (in another post a moderator solved this for me) in any case, problems like this seem to be cascading... i'd appreciate some thoughts on the matter.

Thanks.

Link to comment
Share on other sites

Ok, i sort of figured out the answer by myself by reading a similar post.

So I'll explain for whoever has the same issue:

Some modules (eg. best sellers block) only have code to be adapted to certain hooks (hook is the way positioning areas are called, left column, header, etc are hooks), so if you want to use them in other hooks you will need to manually edit the php file for that module and tell the thing how to do so.

I'll give the example i solved:
As i said, i wanted the "best sellers" block to show on the home page content, so...

I opened modules\blockbestsellers\blockbestsellers.php and modified the code like this:

found this line:

!$this->registerHook('rightColumn') OR


and added right below:

!$this->registerHook('home') OR



notice how i just copied the first line and changed "rightColumn" for "home".

Then found this code:

function hookRightColumn($params)
   {
       global $smarty;
       $currency = new Currency(intval($params['cookie']->id_currency));
       $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 5);

       $best_sellers = array();
       foreach ($bestsellers AS $bestseller)
       {
           $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic(intval($bestseller['id_product'])), $currency);
           $best_sellers[] = $bestseller;
       }
       $smarty->assign(array(
           'best_sellers' => $best_sellers,
           'mediumSize' => Image::getSize('medium')));
       return $this->display(__FILE__, 'blockbestsellers.tpl');
   }



and copied it exactly just below and before the

function hookLeftColumn($params)


but changed the "hookRightColumn" to "hookHome".

I assume this is pretty rough and non-elegant, but it's an invitation to others to further expand on the issue.

Hope it does the trick for you guys!

Greetings.

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