I am currently developing a prestashop module where the user can add as many visual elements (an accordion) as he wishes. I finished the configuration of the back office with my own database, everything is ok on that side.
The problem comes from the fact that depending on the hook chosen by the user (displayHome or a custom hook) the visual element will be added to it.
During my testing phases, I managed to display the corresponding visual rendering on the displayHome hook, via this method in my main file :
public function hookDisplayHome($params)
{
$this->context->smarty->assign([
//...
]);
return $this->display(__FILE__, 'my_file.tpl');
}
The prestashop documentation for the FrontController explains how to configure it for visual rendering on a custom page, but nothing related to hooks.
I tried a similar process with the initContent() method but it doesn't seem to work.
I think that if() will be enough to assign the variables to different places according to the choice of the user. But if I can't just display it, I won't be able to think about it anyway.
How to interact with hooks via the FrontController ?
Related
I have implemented custom error pages in my Laravel project but now run in to a situation where I actually want to fallback on displaying the default ones. The application consists of an admin area and 'front' area. I created the custom error pages for the front area but want to fall back on the default ones for the admin area.
The request comes in via the app\Exceptions\Handler.php, render() method which calls its parent render() method in vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php. I'm kind of stuck at the convertExceptionToResponse() method within this class which seems to be called in case of a custom template but not in case of a default template.
Can you guys help me out?
I figured it out thanks to this post Is it possible to create separate error pages for the backend and frontend in laravel?
What I did was copy the dafault error pages to the subfolder /admin, we probably will customize them in the future anyway.
protected function getHttpExceptionView(HttpExceptionInterface $e)
{
if (isAdminPage()) {
return "errors.admin.{$e->getStatusCode()}";
}
return "errors::{$e->getStatusCode()}";
}
I'm working on my own store, and I want to add some custom functionality. But this functionality is not something standalone, so I'd prefer to completely implemented via overriding controllers/classes and not to create a separate module for this.
But I have to use some hooks (for example - displayAdminProductsExtra to add new tab to admin product page, or actionProductAdd/actionProductUpdate to make some custom edits to DB). I know the way to use hooks from within the modules, but I cant find the way to do without creating my own module).
So the question - is there a way to do so?
Thanks in advance.
Hooks are only meant to be used with modules.
When Hook::exec() is called it will first check if a module is attached to this hook and stop otherwise.
Here is the related code:
// If no modules associated to hook_name or recompatible hook name, we stop the function
if (!$module_list = Hook::getHookModuleExecList($hook_name)) {
return '';
}
I created a custom plugin for my joomla extension, it all works well while trying to trigger it from a template override (just for test).
But when I try to fire it from the extension model (the same code that works in the override) it doesn't trigger the event.
Is there anything specific that needs to be done to the extension to be able to trigger it from the model?
here is what I am using and works in the template override but doesn't work in the model
JPluginHelper::importPlugin('bookingnotification');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onHelloWorld', array());
I am clueless
I found the answer to own my question.
For some reason if I am triggering the event from a template override I can specify only the plugin folder in the importPlugin, like below
JPluginHelper::importPlugin('bookingnotification');
But if I am triggering it from the model it will only work (or at least in my case) if I specify the the group and the plugin folders, like below
JPluginHelper::importPlugin('user','bookingnotification');
I hope this helps some else
I want to override prestashop's default front-office template and controller in my newly created module without modifying prestashop's internal code/structure.
Example :
I have created one module i.e. "mymodule" in /modules folder where I want use prestashop's address form (address.tpl).
see : http://demo-store.prestashop.com/en/address.
I want to enhance address form by providing some additional fields/functionality but without changing prestashop's core functionality.
So, How can I override its controller/themes/templates in my module? I have searched lot of about this on google but didn't found anything :(
Any help would be appreciated.
Modules can work like you ask only if there's an HOOK inside the template/controller that allow you to run your customized function. Look if you have a chance of hooking your module somewhere by watching on the list showed inside
backoffice > modules > position
the Address controllers hasn't got any Hook if i recall well, so you have 3 ways to edit its functionality:
Go for an (imho) horrible client-side modification, by an heavy usage of jquery/ajax call to perform the action you need. Place the code by using a module that only add your js script in the header by using the hookHeader() function. Since this hook it's always called in all the site you can exploit the missing hook in the address template.
add yourself an hook inside the Controller and the template by following this procedure: http://www.prestashop.com/forums/topic/218291-create-custom-and-new-hook-in-ps-15/
use the amazing override features of the prestashop framework to modify what you need in the Controller file placed inside your prestashop_root/override/controllers/front/AddressController.php and inside your /prestashop_root/themes/my_theme/address.tpl. this way you can ovverride any function of the Controller withouth loosing the original functionality and if you'll need to upgrade your installation you will just need to check for the function you changed in the overrided file just as you would do for your module.
Due to some custom modifications in the hierarchical_select module I need to be able to override the the taxonomy_field_validate function in the core taxonomy module.
I've tried creating a function in a custom module called MYMODULE_taxonomy_field_validate which it doesn't pick up on and I tried changing the field settings, but that changes how the data is stored in the database and it needs to be kept as a taxonomy term.
Any other ideas?
You need to unset this function on form validation.
In your module, write a hook_form_alter implementation and write this code inside
unset($form['#validate']['taxonomy_field_validate']);
Hope this works.