I am trying to add new custom hook:
theme.yml
custom_hooks:
- name: displayUnderTop
title: displayUnderTop
description: Add main menu in the header
and view:
{hook h='displayUnderTop'}
but in admin dashboard I don't see new hook. I tried to recompile template files but to no avail. How to make this hook appear on the "positions" list?
Ok Solved:
i just unzip other theme, changed to new, and change back to classic theme. It work's :)
Related
I need to add my custom button to the order page, best if near edit/delete, it should just open link for some route with orderId parameter.
Also it would be nice to remove unnecesary buttons like discount and coupon code.
How to do that? I tried to do smth with placeholders but didnt succeed.
These buttons are rendered using actions:
The code that renders "Edit" and "Delete" buttons
Actions documentation
But, if your button just renders a link, you can override the {% block navButtons %} block in OroOrderBundle:Order:view.html.twig template. See how to override templates.
Or, you can extend the button list without template inheritance, using placeholder view_navButtons. See placeholders documentation.
Decided to use action as its very smart and powerful mechanism even for such simple thing as download button, dont need to override templates or work with templates at all. So here is all that need to display the button:
#MyBundle/Resources/config/oro/actions.yml
operations:
download_action:
label: Download
button_options:
icon: fa-download
routes:
- oro_order_view
entities: ['Oro\Bundle\OrderBundle\Entity\Order']
for_all_entities: false
actions:
- '#redirect':
route: 'test_download'
route_parameters: {id: $id}
new_tab: true
preconditions:
'#equal': [$internalStatus.id, 'open']
The only confusing thing is that button appeared not only on oro_order_view page but on edit page too despite of specified route, anybody knows why?
Goodmorning everyone. I'm going crazy behind a very simple new hook.
I just wanted to add the share buttons in the blog articles, I added the hook in theme.yml as shown in the image, I reset the theme and the module but nothing to do, I don't see the hook if I try to insert the module.
Moreover from this insertion onwards I am no longer able to reset or uninstall the module, it returns me the error you see in the image. What am I doing wrong?
img01
img02
Check if your hook exists in the ps_hooks tables if not add it there.
You need to register it in the ps_hooks database,maybe the ideal can be to create a module, and in the installation register the hook and assign a template that shows what you need in the hook.
Prestashop documentation
I try to create a custom Hook for Prestashop 1.7.0.3 for the slider module. I insert:
displaySlider:
- ps_imageslider
on theme.yml file on block “hooks”.
Then insert:
{if $page.page_name == 'index'}
{hook h='displaySlider'}
{/if}
on theme/templates/layouts/layout-both-columns.tpl file between header and section id=”wrapper” tags. According to this article: Custom Hooks in Prestashop 1.7 everything will work ok but the hook is not shown on available hooks when i try to change slider module position from the backend.
I was working today on the same issue.
And i succeed to make it appear, it is probably not the good way and i hope it is not the good way because it is weird.
In your theme.yml you have to set your hook like this :
global_settings:
hooks:
custom_hooks:
- name: displayFooterBefore
title: displayFooterBefore
description: Add a widget area above the footer
And if you wanna see your hook in the position page, you have to switch to a other template and back to your one. (Kind of refresh)
You can also check the incomplete doc from Prestashop :
http://developers.prestashop.com/themes/hooks/index.html
I hope there is a another way to refresh hooks in this page...
So just to be clear. To add a new hook in Prestashop.
In \themes\yourTheme\config\theme.yml you add
custom_hooks:
- name: displayYourCustomHook
- title: displayYourCustomHook
- description: This is a Custom hook
In the same file, in the section modules_to_hook:
displayYourCustomHook:
- ps_moduleIwantoHook
- ps_anotherModuleIwantToHook
Wherever in your .tpl files you want to add your hook:
...
{hook h='displayYourCustomHook'}
...
Finally, from you backoffice, you change from your current theme to a differente one, and then save. After that, you change to the previous theme (the theme you actually want to use), save again and your hook should be visible. This is done with the aim of "refreshing" the hooks that your Prestashop site recognasizes.
This is working in Prestashop 1.7.7
I spent a lot of time looking for why my custom hook did not appear on the front, thanks for the tip.
In order to improve the process, you can use the reset button in appearance > themes & logo.
This avoids having to activate another theme.
I see I voted myself for the accepted solution 2 years ago, but now came up with a much better solution.
According to Prestashop 1.7 hooks doc all you have to do is to register your hook as any other normal and it will be automatically created. So paste something like:
$this->registerHook('displayAtSpecificPlace');
in your module install() and reinstall the module.
How or where is this variable defined in stencil?
{{ getFontsCollection }}
I'm hoping to include other google fonts in the theme. Are they automatically included if they are listed in schema.json?
According to the Stencil Docs, getFontsCollection is a handlebars injection helper function used to help you load the resource on the page:
{{getFontsCollection}}
The getFontsCollection helper is custom to Stencil. It returns a link tag that loads all selected font collections. It takes no parameters.
The helper method pulls from your global getThemeSettings() which are located in your config.json file. Look for the primary-font and secondary-font fields
"settings": {
"primary-font": "Google_Lato_700,400,300",
"secondary-font": "Google_Droid+Serif_400italic,400,700",
...
}
They are added via the config file
i have very strange problem with latest version of prestashop installed when i unhook quick search block from displayTOP then slider and products got disturbed on page then i have to disable Quick search block from modules after that it works fine.
actually i want to display Quick search block separately on top using header.tpl file with
method
{include file=$tpl_dir./modules/blocksearch/blocksearch-top.tpl}
kindly help me to resolve this issue i'm customizing the default-bootstrap theme and using prestashop 1.6.0.9
Regards
You may create a custom hook and attache the module quick search block to this hook and in the tpl call your new hook where you want like ! {HOOK_YOURHOOK}
in your module :
public function hookDisplayQuickSearch($params)
{
$this->hookTop($params)
}
in header.tpl add
{HOOK_DISPLAYQUICKSEARCH}
Notice : i didn't try the code