Comments (12)
Thank you for your patience with me.
Acutally, I dont want to create a new module, but to set a hook in the theme, that i can see in the back office and place an existing module there.
from docs.
Hi,
You must have a look on https://devdocs.prestashop.com/1.7/modules/concepts/hooks/
Hooks are register with install
method. If you add new hooks after installed your module, you need to reset it :)
Regards
from docs.
In the manual they showed two way to create hooks:
From a regular PHP file:
Hook::exec('MyCustomHook');
or
From a Smarty template:
{hook h='MyCustomHook'}
I choose the later for simplicity but it didnt work
from docs.
It's not to create Hook, it call a registered hook.
The wording is not clear, but your are looking for Theme hook.
The procedure is :
- Create a module
- Add some hook with
registerHook
duringinstall()
process. (Register Hook)- if something wrong, uninstall and install module again
- Add methods corresponding to the selected hook. (Execute hook)
If you create a custom theme and want to add a custom hook for example MyAwesomeDesign
:
<div>
{hook h='MyAwesomeDesign'}
</div>
You must have this in your module:
public function install()
{
return parent::install() && $this->registerHook('MyAwesomeDesign');
}
public function hookMyAwesomeDesign()
{
// Something I want to do while calling 'MyAwesomeDesign' hook in my theme
}
Hope I help you =)
from docs.
No probleme, I'm here to help you :)
The only way to register a hook in database is to have a module which use the registerHook
function.
Without module, a hook is useless, in my previous example, hook is called with hookMyAwesomeDesign
. So if you create a hook without module, it will never called.
Regards
from docs.
how about creating a new hook, for an existing module ?
from docs.
What do you mean? Adding a new hook in the core?
Otherwise all registered hooks are related to modules, you can add upgrade directories like this modules: https://github.com/PrestaShop/ps_customtext/tree/master/upgrade to register new hooks or write anything you want during upgrade :)
from docs.
Hey, just found this link https://devdocs.prestashop.com/1.7/modules/creation/enabling-auto-update/#adding-updating-modules-or-hooks-between-versions
from docs.
Hello @Xsmael,
as your questions have been answered I'm closing this.
Feel free to re-open or to open a new issue if you need helps.
from docs.
So you cannot create hook just in the template, so you could later position modules to it? Let's say I need two new hooks in product page, but without any specific module, just to have it in "positions" to attach there any module I want. Isn't the theme.yml file for it? If not, then what is the purpose of registering hook in the theme.yml?
from docs.
@grzegorzgit you can indeed register new hooks and modules to it, but if module doesn't implement hook properly there's nothing to display
most of modules are treated as widgets maybe this helps you out a bit?
from docs.
I have the same problem. I want to register new hook and place in it module (already installed in my shop)
How to do that. I made custom hook in the theme.yml but I cant see it in Positions in the dashboard. How to make it visible to installed modules to move them to it?
from docs.
Related Issues (20)
- Tip regarding SF services loaded from the directory
- PS8: Document NavigationTabType with an example module
- Hook displayFooterCategory is missing
- Webservices - Add example to create a product from A to Z (categories, images, ...)
- Update description of example-modules
- Instruction on how to handle SSL config for autoupgrade module
- Bad links to theme templates HOT 1
- documentation module example produces an error HOT 3
- Few FO hooks are not listed in the dev doc HOT 7
- There are some errors between the BO and FO hooks in the dev doc HOT 2
- Module naming conventions should allow underscore HOT 2
- Adding a configuration page with Symfony forms HOT 7
- Forms subjects : simplify / refactor / re-arrange whole documentation
- Hooks in humminbird, links to the hooks documentation HOT 1
- Refactor the script to extract hooks, to ensure devdocs is up to date
- Missing documentation for hook actionAfterLoadRoutes
- Document using db through unix socket
- Cannot download language pack "en" HOT 1
- Set up PrestaShop 9 documentation branch HOT 1
- Mark documentation for PrestaShop 1.7 as not maintained
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.