Jump to content

Override module controller in theme in Prestashop 1.5


webplus

Recommended Posts

Hi,

 

my question is related to Prestashop 1.5. Module bankwire now contains file /bankwire/controllers/front/payment.php which overrides ModuleFrontController.php. It removes the left column during bankwire payment. I want to change this for my theme so I wonder if I can override it within theme? I tried to change it via /themes/mytheme/modules/bankwire/controllers/front/payment.php but it doesn't work.

 

Thanks for any tips!

Link to comment
Share on other sites

  • 3 months later...

I have the same problem!

 

Hi.

 

First you need to edit global.css line 1703 (if default theme) and remove:


#module-bankwire-payment #left_column {


display: none;
}

 

Then edit 'modules/bankwire/controllers/front/payment.php' and remove line 33:

public $display_column_left = false;

 

Regards.

 

Robin.

 

The CartExpert Team

Link to comment
Share on other sites

Hi Alexander,

 

thank you for joining the topic and your tip. You are right, it's probably the only possible workaround if I don't want to hide left column during checkout in theme for sale. But I would have to do the same for cashondelivery, cheque and maybe some other modules and keep them updated with every new version. I think this wasn't a good idea to hardcode hiding of column into modules, as it limits theme developers in case they just don't want to hide the left column during checkout.

 

Thanks everyone. I'm just not sure if I should mark the topic as solved :)

Link to comment
Share on other sites

Hey,

i just want to drop in my .2 about this.

Why is the Prestashop team ignoring this AWFUL module behavior? There are a couple of issues opened in the forge, and i also opened another topic about this, but both are being ignored. geez.

For the time being, I'm giving my custoemrs a front controller override where the "hide columN" command has been disabled. But this is a pain!

Furthermore, even if for some reason it was possible to override the modules' php files, this would have meant adding tons of overrides, since a whole lot of modules interfere with the layout.

 

 

What do you think? I'd say: let's massively tell the prestashop team to remove this stupid feature, which is making life much harder to all theme developers!

 

;)

 

Cheers!

  • Like 4
Link to comment
Share on other sites

  • 5 weeks later...

Why not create a module with your themes that installs a new hook on the left side, and during the theme install have the modules installed to the new hook.

 

Because it will be a work around, and this will make conflicts with feature modules that user may install on this theme :) I have also submitted the problem as bug http://forge.prestashop.com/browse/PSCFV-5001 they are working on a solution :)

  • Like 1
Link to comment
Share on other sites

I haven't thought about this in a long time, but am I wrong in thinking that if you use your own classes and names that the modules cannot hide the columns?

 

You can do it if you export module, but for themes is bad.

 

In themes is not good to use your own classes, because it makes installation harder for users to understand when they need to upload/preserve classes with upgrades/installs, it would be ok if ThemeInstaller export/import override classes, but until then it is not good idea.

 

Edit: The only reasonable solution is either PrestaShop fix this, or you should make a custom module in which you can put your override class so it can be exported and imported with theme installer.

Edited by Dreamtheme (see edit history)
Link to comment
Share on other sites

Oh Jeez. What are they thinking? This is what makes me wonder how long Prestashop will survive. Customization ease is going nuts :(

 

I saw from 1.4.x to 1.5.x at least 20 developers who abandoned PrestaShop, with 1.5.x PS showed that they don't care for developers, customizing or backward compatibility, if this behavior continue i bet PS future won't be bright.

Link to comment
Share on other sites

I saw from 1.4.x to 1.5.x at least 20 developers who abandoned PrestaShop, with 1.5.x PS showed that they don't care for developers, customizing or backward compatibility, if this behavior continue i bet PS future won't be bright.

 

Agreed, i also work with Wordpress, and there is, among the others, one HUGE difference between the two project: Wordpress is designed to be extended, for the end user and developers. Prestashop seems to have been created to advertise some partners, more and more... and more! Sad.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi

I'm very new here and to this cart but surely you just edit

/override/classes/module/Module.php

to

 

<?php
abstract class Module extends ModuleCore
{
/**
  * Return an instance of the specified module
  *
  * @param string $module_name Module name
  * @return Module
  */
public static function getInstanceByName($module_name)
{
 if (!Validate::isModuleName($module_name))
  die(Tools::displayError());
 if (!isset(self::$_INSTANCE[$module_name]))
 {
  if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/'.$module_name.'.php'))
  {
include_once(_PS_THEME_DIR_.'modules/'.$module_name.'/'.$module_name.'.php');
if (class_exists($module_name, false))
 return self::$_INSTANCE[$module_name] = new $module_name;
  }
  if (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'.php'))
  {
include_once(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'.php');
if (class_exists($module_name, false))
 return self::$_INSTANCE[$module_name] = new $module_name;
  }
  return false;
 }
 return self::$_INSTANCE[$module_name];
}
}

 

Its ment for editing core features!

 

I just added the lines to the getInstanceByName() function that make it first search the theme directory for the php file first i.e. /themes/my_theme/modules/my_module/my_module.php

If it finds one it uses it

 

You may want to redirect it to a more v1.5 path

Cheers

mh

Link to comment
Share on other sites

There are several problems with this approach.

 

1. The problem with overriding default behavior is that this php files should be placed manually, and will not work with Theme Installer module, this means that users will have to do manual stuff and this is always bad.

2. The second problem is updates, if the users upgrades his version he will lose this and he must do it again.

3. You then should mark your theme as "core modified" in addons store which is bad.

 

The only viable solution should be to imbed some kind of class override inside some custom module. However i think that this is just very bad, because showing or hiding columns should be CSS controlled only! And it was that before, i don't know what gone wrong in 1.5.x

  • Like 1
Link to comment
Share on other sites

Excuse my ignorance, i am new ;)

Think we're coming at the problem from different paths

I was looking at a way to modify the core modues without actually editing them. So they'd live on through upgrades etc.

(Are you sure an upgrade will overwrite stuff in the \override folder?) Just looked through the manual upgrade steps and the \override folder is replaced. Thats a bit rubbish!

 

I see that you're more interested in being able to package a theme and have it work without touching anything system (or at least not have your users have to touch it)

Your point is valid as column hiding should be CSS controled.

mh

Edited by mhume (see edit history)
Link to comment
Share on other sites

No problem :) i welcome your attempt :P

My experience shows that users have difficulty installing simple logo in PrestaShop, and forcing them to override files will make things much worse :D That's why this problem should be solved foolproof, and i think only PrestaShop team can do it.

Link to comment
Share on other sites

Would I be wrong in thinking that all you would have to do is write in a jquery routine, on page, that would unhide the element? As an alternative couldn't you just by pass this by not using the standard left column naming convention in your theme?

Link to comment
Share on other sites

Would I be wrong in thinking that all you would have to do is write in a jquery routine, on page, that would unhide the element? As an alternative couldn't you just by pass this by not using the standard left column naming convention in your theme?

 

I don't understand, how you will override public $display_column_left = false; in bankwire module with jquery?

Link to comment
Share on other sites

// Call hook before assign of css_files and js_files in order to include correctly all css and javascript files
    $this->context->smarty->assign(array(
  'HOOK_HEADER' => $hook_header,
  'HOOK_TOP' => Hook::exec('displayTop'),
  'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),

 

Its seems to be hook, nothing to do with jquery.

Link to comment
Share on other sites

I am just making a guess here, and you can tell me if I am wrong. I usually design one off themes for clients, so I don't have the expertise in developing themes for distribution. What would it do if you wrote a module and distributed it with your theme. The module just basically hooks into the foot and re sets the variable on the left column.

Link to comment
Share on other sites

Well, i state it before, to make external module is the only good solution. But this will take resources and will slow down PS even more.

 

I have run bug report about it long ago, and Vincent AUGAGNEUR said:

 

"At the moment we are currently stabilise the version 1.5.

We are working about found a solution on this problem too."

 

But this was back in October, 5 months later and nothing yet about it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...