Closed PubliAlex closed 6 months ago
Hi, i'm actually working on it, it works fine on version above > 8 but, in 1.7 i'm some issue.
It looks like you have to name your hooks:
beforeRenderingallbrands
and rename it in database.
the code is executed here:
https://github.com/PrestaSafe/prettyblocks/blob/d6fda1c73ac2129971ca286a656ffd2bbf631323/classes/PrettyBlocksModel.php#L249
i'm on it. Thanks
Hi, i'm actually working on it, it works fine on version above > 8 but, in 1.7 i'm some issue. It looks like you have to name your hooks:
beforeRenderingallbrands
and rename it in database. the code is executed here:i'm on it. Thanks
I'm on 8.1 and it doesn't work with all name tested above + your suggestion : beforeRenderingallbrands
I don't understand the sentence : and rename it in database, what should I rename in database ?
In PrettyBlocksModel.php when I dump
Tools::toCamelCase($this->code)
I get "allBrands"
So, if I understand your code, my method name must be :
public function beforeRenderingallBrands()
I tried, but still nothing. But as I dont understand what do you mean by "rename in the databse", maybe I miss something
so you method should be:
public function hookbeforeRenderingallBrands
i've to make for tests on that point, almost on 1.7 versions.
Ok, tested with that name, don't work on prestashop 8.1.
Let me know what should I do to make it works
Check how the hookname is registred in prestashop (database ps_hook) and check if your module is well registred on it
Hello,
After many many tests, I could find something working.
I installed hook_manager to manage hooks, and I created a beforeRenderingallBrands
Then, in in the hook module page, I associated my custom block module to that hook, to get something like this
(I hide the customer name that is in the module name)
Then, in my block code, I could dump something by using this code :
public static function beforeRendering(array $params = null): array {
dump('beforeRendering');
return ['brands' => false];
}
Several things to notice :
If it can help
thanks for your feedback
Hello,
There is a bug (at least in the documentation) cause it's impossible to make the beforeRendering hook to works.
I have block AllBrands that works, but I want to use the beforeRendering hook to get list of all my brands and make it available as smarty variable in my view.
My Class name is : AllBrands My block code is : all_brands
So, by following the documentation, I create a method
beforeRendering{BlockCode}
(with {BlockCode in camelCase})So I get something like this :
I tried all possible name cause documentation is not clear here, in your documentation you take the example of a block : block_category_products, which lead to hookbeforeRenderingblockCategoryProducts method. Several errors compared to what you say above :
So, finally, by following the documentation, you don't know how to name the function. But I tried everything in my case :
Could never see my dump, so I think there is something deeper than just a name.
Can you confirm what is the right syntax to use, and fix the documentation by the way ? Can you check that this hook works well ?
Thank you