Need help on a minimal module for prestashop 1.7.x - prestashop

I would like to write a module for prestashop 1.7.x for the first time !
It would be nice if someone could give me a hint how to start up.
I would like to use a php function with smarty call like {$page.page_name|test}

Hi #Hardy Thiergart and welcome to SO!
You can easily write your first PrestaShop module by following the tutorial here:
https://devdocs.prestashop.com/1.7/modules/creation/
Main steps:
Create a folder with your module's name
Create a PHP file with the same name
Make sure your PHP file contains at least the __construct(), install(), uninstall() and getContent() methods (the last one is required only if you allow users to 'Configure' this module)
You can then add additional methods for Hooks, including calls to your template files
Once ready, create a zip file of this folder, with your module's name
I hope this helps.

Here is a link to generate an empty Prestashop module with hooks, etc ... : https://validator.prestashop.com/auth/login
Regards

Related

Create New Hook To Call module blocksearch Inside Another Module

I need to put blocksearch module into a leomegamenu module, my problem is how to do that(that is which files to modify. Can somebody give me pointers to which files to go.
thanks in advance
If you look at blocksearch.php. It is linked to hook hookDisplaySearch.
In your leomegamenu template files you can add this code:
{hook h='displaySearch' mod='blocksearch'}

PrestaShop - Overriding module CSS files

Im using Prestashop 1.6.0.9 and a module called agilemultipleseller.
Basically it turns your shop into a multi vendor store.
There are 2 CSS files that the module inserts that i need to override.
I cant take the reference to the CSS out of the module file as they are encoded.
The module structure is as follows:
/module/agilemultipleseller/css/agileglobal.css
/module/agilemultipleseller/css/agilemultipleseller.css
I have tried overriding the CSS files by placing my own in the following location
/themes/my_theme/modules/agilemultipleseller/css/agileglobal.css
Could anyone with knowlegde give me a pointer or 2.
Cheers,
If the module is designed with overrides support the paths should be:
/themes/my_theme/css/modules/agilemultipleseller/agileglobal.css
/themes/my_theme/css/modules/agilemultipleseller/agilemultipleseller.css

Dotnetnuke - How to insert a module inside another module?

I am writing a Tabs module in which I want to be able to display other modules like html, third-party modules etc. How do I achieve that? C# code please.
http://www.mandeeps.com/products/dotnetnuke-modules/live-tabs.aspx
This module is a tabs module that does just what you are looking to do.
I don't think it's the type of thing someone can just code up for you or copy and paste it in here. You could use this module, you could buy the source of this module or you could analyze the source of DNN and figure out what really makes a module render and reproduce that.

how to call only blocktopmenu module in prestashop

can anyone tell me how to call only blocktopmenu module in prestashop...if i use displayTop hook it calls various other modules along with it..but i only want to call blocktopmenu..is it possible to create an object of Blocktopmenu class and access the hookDisplayTop() of that class..so that i can avoid other modules...i tried but its not working
when i try to implement this
Call Module in tpl file in prestashop
it shows "This module cannot be transplanted to this hook."
When you call Hook::exec() you can specify a module ID in the 3rd parameter.
It would be something like that:
Hook::exec('displayTop', null, Module::getModuleIdByName('blocktopmenu'));
Regards,
Never touch the FrontController.
You have to create a new hook, then attach your module to this hook.
After that, you can call Hook::exec('your_hook').

Yii - Using alternate view file in Yii User module

Is it possible to use a custom view file in a module (eg. user) in order to keep the module (3rd party) intact?
Somehow extend the module, with a views folder that holds my custom views.
The path to the module theme views should be
/{{your_app_name}}/themes/{{theme_name}}/views/user/
Copy all of the module views from the folder
/{{your_app_name}}/protected/modules/user/views
to the mentioned above folder and that will do the job. After that you could customize the views as you like.
Copy user module view files to <app>/themes/<current_theme>/views/user/. More general, customize module views using the folowing "formula": <app>/themes/<current_tehem>/views/<modules_name>/<controller_name>/<view_file_to_customize>.php
Use a theme. For a module named "user" and a view path of "profile/edit", create "/themes/flashy/user/views/profile/edit.php". You can also define a new layout in "/themes/flashy/layouts/column2.php". Then add to your configuration file in "protected/config":
return array(
// many settings...
'theme' => 'flashy',
For the module "user" you pointed out, unfortunately its controllers use absolute paths for their layouts (e.g. "//layouts/columns2") so AFAIK you can't define distinct layouts for the application and this module.
See also the official guide chapter on theming with Yii.
I disagree that in many help forums of the Internet, when someone asks abot theming a module, everyone suggests a path alias to the themes folder. I think this is wrong, because it implies modules to be splitted, and modules are supposed to be a black-box that can be used across projects. The advice given in such forums would only be valid if a theme is shared among several modules. If someone wants to "package" a theme inside a module, she can:
-add an init function to the controller of the module
-inside that init, use the class attribute layout and a path alias, like this, supose a module whose id is "Sample":
then you add, to SampleCOntroller.php:
public function init() {
//BELOW: it will use the layouts/main.php inside the module.
$this->layouts = "sample.views.layouts.main";
}