{"id":6827,"date":"2019-02-24T11:00:58","date_gmt":"2019-02-24T05:30:58","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=6827"},"modified":"2024-04-09T18:29:18","modified_gmt":"2024-04-09T12:59:18","slug":"insert-custom-hooks-in-prestashop","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/prestashop\/insert-custom-hooks-in-prestashop\/","title":{"rendered":"How to Insert Custom Hooks in PrestaShop 1.7?"},"content":{"rendered":"<p>Do you know how to insert custom hooks in PrestaShop 1.7? Because it&#8217;s most important thing to add your own hooks while development of theme or module using PrestaShop 1.7. In this tutorial I will guide you to add your custom hooks. Follow the below steps,<\/p>\n<div style=\"display: block; float: left; width: 100%; border-radius: 5px; margin: 0 0 25px 0;\"><a style=\"color: #fff; font-size: 28px; font-weight: 600;\" href=\"https:\/\/addons.prestashop.com\/en\/analytics-statistics\/92705-google-analytics-google-analytics-4-ga4-integration.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-13583\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/2018\/11\/google-analytics-prestashop-ga4.gif\" alt=\"\" width=\"780\" height=\"110\" \/><\/a><\/div>\n<p>1. Go to <strong>Theme directory \/ config \/ theme.yml<\/strong> file and find the block \u201c<strong>hooks<\/strong>\u201d:<\/p>\n<p>2. Inside the hooks block add the below construction<\/p>\n<pre>\r\n\r\n     custom_hooks:\r\n       - name: yourCustomHookName\r\n         title: yourCustomHookName\r\n         description: Adds Block before the footer block\r\n\t\r\n\t\r\n<\/pre>\n<p>Modified file will be look like as below.<\/p>\n<pre>\r\nglobal_settings:\r\n  configuration:\r\n    PS_IMAGE_QUALITY: png\r\n  modules:\r\n   to_enable:\r\n     - ps_linklist\r\n  hooks:\r\n    custom_hooks:\r\n      - name: yourCustomHookName\r\n        title: yourCustomHookName\r\n        description: Adds Block before the footer block\r\n    modules_to_hook:\r\n      displayNav1:\r\n        - ps_contactinfo\r\n      displayNav2:\r\n        - ps_languageselector\r\n        - ps_currencyselector\r\n        - ps_customersignin\r\n        - ps_shoppingcart\r\n\r\n<\/pre>\n<p>Here, We have just registered custom hook so it can be accessible in any template.<\/p>\n<p>3. Now, you need to place hook in the template file. For example, <strong>Go to : Theme directory &gt; templates &gt; _partials &gt; footer.tpl<\/strong><\/p>\n<p>4. Now add the custom hook as below,<\/p>\n<pre>\r\n{hook h='yourCustomHookName'}\r\n\r\n<\/pre>\n<p>Modified file will be look like as below.<\/p>\n<div class=\"container\">\n<p>&nbsp;<\/p>\n<div class=\"row\">{block name=&#8217;hook_footer_before&#8217;} {hook h=&#8217;displayFooterBefore&#8217;} {\/block}<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>{hook h=&#8217;yourCustomHookName&#8217;}<\/p>\n<div class=\"footer-container\">\n<p>&nbsp;<\/p>\n<div class=\"container\">\n<p>&nbsp;<\/p>\n<div class=\"row\">{block name=&#8217;hook_footer&#8217;} {hook h=&#8217;displayFooter&#8217;} {\/block}<\/div>\n<p>&nbsp;<\/p>\n<div class=\"row\">{block name=&#8217;hook_footer_after&#8217;} {hook h=&#8217;displayFooterAfter&#8217;} {\/block}<\/div>\n<p>&nbsp;<\/p>\n<div class=\"row\">\n<p>&nbsp;<\/p>\n<div class=\"col-md-12\">\n<p>&nbsp;<\/p>\n<p class=\"text-sm-center\">{block name=&#8217;copyright_link&#8217;} <a class=\"_blank\" href=\"http:\/\/www.prestashop.com\" target=\"_blank\" rel=\"noopener\"> {l s=&#8217;%copyright% %year% &#8211; Ecommerce software by %prestashop%&#8217; sprintf=[&#8216;%prestashop%&#8217; =&gt; &#8216;PrestaShop\u00e2\u201e\u00a2&#8217;, &#8216;%year%&#8217; =&gt; &#8216;Y&#8217;|date, &#8216;%copyright%&#8217; =&gt; &#8216;\u00c2\u00a9&#8217;] d=&#8217;Shop.Theme.Global&#8217;} <\/a> {\/block}<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p>That\u2019s all. Once you upload the theme, you will find the above hooks on the transplant module page to transplant your module before the footer container block.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you know how to insert custom hooks in PrestaShop 1.7? Because it&#8217;s most important thing to add your own hooks while development of theme or module using PrestaShop 1.7. In this tutorial I will guide you to add your custom hooks. Follow the below steps, 1. Go to Theme directory \/ config \/ theme.yml&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/prestashop\/insert-custom-hooks-in-prestashop\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":6970,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221,222],"tags":[624,313,329,625],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/6827"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=6827"}],"version-history":[{"count":20,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/6827\/revisions"}],"predecessor-version":[{"id":13602,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/6827\/revisions\/13602"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/6970"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=6827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=6827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=6827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}