Leo Bootstrap Megamenu Error In Prestashop - prestashop

I'm starting to learn Prestashop, so I've downloaded a free theme and started to edit it. But I have a problem with the navbar and now I need to edit it.
This is my navbar:
I need to add all my categories to the category section of the navbar, but I'm not able to do it. This theme uses Leo Bootstrap Mega Menu. So when I edited that module to add a product, it gives me the following error:
How would I fix this?

Your theme or module uses a function that is not included in your version of Prestashop. Try to put this function in your classes/Language.php file before the last }.
/**
* Returns an array of language IDs.
*
* #param bool $active Select only active languages
* #param int|bool $id_shop Shop ID
*
* #return array
*/
public static function getIDs($active = true, $id_shop = false)
{
return self::getLanguages($active, $id_shop, true);
}

As for #Roman K suggestion. I recommend you should add the code to overrides folder. It will be easier for you when you upgrade to new version of Prestashop.
If you still get the error. I think you should download other Prestashop Mega Menu Module.

Related

In Opencart 3 under PHP 8 how do I call module to show in another page

I have seen on this site the post re calling a module on needed page. I have tried to use this code to solve a problem. This code does not appear to work for me.
What I have is a module that places a label over each product depending on its status. It works well on products throughout site. However I have a module which calls all products on to one page. I want the label to appear on the products on this all products page.
Banner on product
The code I used in catalog/controller for the all product extension from previous post here was (382 is the label module number):
$this->load->model('382');
$my_variable = $this->model_setting_module->getModule('382');
$data['any_variable'] = $my_variable['any_variable'];
On Template page:
{{ any_variable }}
How can I get the module to be apply the label to the custom all products page?
As always help appreciated
Create new module with name: "my_module" and you can call it in your "another_module" controller file:
$data['my_module'] = $this->load->controller('extension/module/my_module');
and in corresponding "another_module" template file you can retrieve it:
{{ my_module }}

How can I change the module position from code in Prestashop 1.7?

I learn actually Module Programming in Prestashop 1.7.... hard work but really good.
So, when I install my first module,
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
if ( !parent::install() or
!$this->registerHook('displayTop') or
!$this->registerHook('header') or
!$this->registerHook('backOfficeHeader') )
return false;
return true;
}
the position will automatically set at the end of the hook displayTop.
Now, what must I do to set it on the first place ?
I have read it will works with the function "updatePosition", unfortunately I find only tips of 2012 and 2-3 years earlyier.
The developer docs have a hint here,
https://devdocs.prestashop.com/1.7/development/components/position-updater/
but I don't understand how to implant it into your module.
Does anyone have the time to explain me how the desired order is laid out by the code?
And does this happen in the install method or from where?
Go to your admin panel, in "**Design**" then "**Position**".
Look for '**displayTop**' in the "**Search for hook**" search bar at your top-right.
Then drag and drop your module which is in the last row and place it in the first row.
Change module's position in the hook list

Creating module on prestashop

i need to create a module on prestashop on product page , im new in prestashop idk how to do that .
This module should be on bottom of page ,it contains product technical description
Can someone tell me how to do that
Ps : i know nothing about prestashop Hooks ....
Thanks in advance!
There is one hook that may fit you.
displayProductFooter
First you have to add the hook registration in your module install function
public function install()
{
...
$this->registerHook('displayProductFooter');
}
Then create a function to display the content in the hook
Save the content you want to display and use the return to send a string with all the HTML you want to print in the product footer.
In the params you will also find some useful variables like the product ID.
public function hookDisplayProductFooter($params)
{
// Your content here
return $output;
}
The same procedure should work with any other hook (as long as it's a display hook)

Show module Content in theme Development [Prestashop]

I am trying to create a theme using Prestashop 1.6 and the Default theme as reference.
Whenever i try
{HOOK_TOP}
in my header.tpl , it display the search,cart modules.
But in my case i just want the search module to be displayed.How can i display only the search block and the signIn,create account i want them to be displayed in another place.
Also can i get any advice or tutorials from where i can learn the theming the right way.I guess i am doing stuff the wrong way.
You can create new hooks for each module you want to display elsewhere.
By default, the blocks you don't want are hooked to TOP.
You need to un-hook those from TOP.
Create new one :
- sql :
INSERT INTO ps_hook (name,title,description,position,live_edit) VALUES ('yourNewHook','title of your new hook', 'description of your new hook', '1', '1');
INSERT INTO ps_hook_alias (alias, name) VALUES ('the alias of your new hook','yourNewHook');
controller :
public function hookYourNewHook ($param) {
if (!$this->_prepareHook($param))
return;
return $this->display(FILE, 'templateofyournewhook.tpl');}
Modify or add a register hook in public function install() : $this->registerHook(' alias of your new hook')
Now you can call your hook in a tpl with {hook h="yourNewHook"}

In prestashop how to write code for disable a module function only for specified categories

I need to disable a module only for a particular category.How do i need to write code for making the module to diable for those categories.
like this (if you want to disable your module for id category 4) :
$id_category = (int)Tools::getValue('id_category');
if($id_category !==4){
//some code
}