Jump to content

Recommended Posts

Posted (edited)

[PS 1.7]

Hi.
How do I put the FronController.php override in my module.
 ./modules/my-module/override/classes/controllers/FrontController.php

After installing my module, FrontController will not be copied to ./override/classes/controller/FrontController.php

What am I doing wrong ?

 

Thanks

 

 

Edited by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites
Posted (edited)

There is a setting in admin interface called "Disable overrides". (It's close to the "Enable debug" setting).

It's possible that you have overrides disabled. That's why.

We use these settings when we are in production (or try to find a problem we don't know where it comes from)
and need to locate the issue as soon as possible ;)

Moreover check (via files browser) that the override does not exist.

Because it may exist but, without having class_index.php deleted, your system can not "see" the changes.

Edited by tapanda.gr
TYPO (see edit history)
  • Thanks 1

Share this post


Link to post
Share on other sites

It does not work even when debug mode is turned off and dev and prod folders are removed from var ...
So I use the Copy function and normally copy the file.

Share this post


Link to post
Share on other sites

Did you reinstall the module? Because on the fury of development we may make so silly mistakes.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you.
Yes, I uninstalled the module and then cleared the cache.
Then I installed the module again.
The copy function is good for me, I'll check if another module is overwriting the FrontController.
If it is already overwritten by another module, I check if there is a function that I want to overwrite.
If there is a function, I will add my own part to it, if it does not, I will insert my entire function.
etc....

Share this post


Link to post
Share on other sites

If you find no solution make fresh local presta and try to install there the module (to be sure there is no intervention from 3rd party stuff).

Also check that the class is

class FrontController extends FrontControllerCore

Besides that, study the code from modules you may have bought either from addons or codecanyon (or other marketplace) because comparing your own module's behavior and the other modules' behavior may result in finding out some sort of fix.

  • Thanks 1

Share this post


Link to post
Share on other sites

Oh yes, I checked everything.
I'll put my entire FrontController here.
A moment please.
I also checked if it is index.php in override folder.

Share this post


Link to post
Share on other sites

added only dt-test-css and dt-test-js

<?php

class FrontController extends FrontControllerCore
{

    public function setMedia()
    {
        $this->registerStylesheet('theme-main', '/assets/css/theme.css', ['media' => 'all', 'priority' => 50]);
        $this->registerStylesheet('theme-custom', '/assets/css/custom.css', ['media' => 'all', 'priority' => 1000]);

        if ($this->context->language->is_rtl) {
            $this->registerStylesheet('theme-rtl', '/assets/css/rtl.css', ['media' => 'all', 'priority' => 900]);
        }

        $this->registerJavascript('corejs', '/themes/core.js', ['position' => 'bottom', 'priority' => 0]);
        $this->registerJavascript('theme-main', '/assets/js/theme.js', ['position' => 'bottom', 'priority' => 50]);
        $this->registerJavascript('theme-custom', '/assets/js/custom.js', ['position' => 'bottom', 'priority' => 1000]);
        
        $this->registerStylesheet('dt-test-css','/modules/dt_test_module/views/css/dt-test-module.css',['media' => 'all', 'priority' => 200]);
        $this->registerJavascript('dt-test-js','/modules/dt_test_module/views/js/dt-test-module.js',['position' => 'bottom', 'priority' => 10]);

        $assets = $this->context->shop->theme->getPageSpecificAssets($this->php_self);
        if (!empty($assets)) {
            foreach ($assets['css'] as $css) {
                $this->registerStylesheet($css['id'], $css['path'], $css);
            }
            foreach ($assets['js'] as $js) {
                $this->registerJavascript($js['id'], $js['path'], $js);
            }
        }
        

        Hook::exec('actionFrontControllerSetMedia', array());

        return true;
    }
}

Share this post


Link to post
Share on other sites

And what's the issue? You don't see the scripts loaded? Maybe because you don't use full paths, but relative ones?

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

My question is why FrontController.php does not automatically copy from my module folder to the override folder after installing my module.

When I manually copy FrontController.php to the override folder, everything works.
I don't use any other paths.

./var/logs is blank, server error log is blank ....

I also tested the clean installation of Prestashop and the same problem.

I'm really tired of programming anything for Prestashop version 1.7.
70% of things for developers do not work as intended, no help, no support.
Prestashop 1.6.1 was amazing, everything was simple and functional.

 

Please try it for yourself if it works.

 

Create a simple module, paste the FrontController.php file into your module and see if it is copied to the override folder.

Edited by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More