Jump to content

Language change results with Unable to load template file


soee

Recommended Posts

Hi,

 

i have fresh PrestaShop 1.7.0.5 installation. It is configured to use Polish language as default one and English was configured as the second available. 

 

When browsing shop with default language all works fine but as soon as i try to switch to English i have this error:

SmartyException in smarty_internal_templatebase.php line 129:
Unable to load template file '/cms/page.tpl'
in smarty_internal_templatebase.php line 129
at Smarty_Internal_TemplateBase->fetch('/cms/page.tpl', null, 'layouts/layout-full-width.tpl', object(SmartyDev), false, true, false) in SmartyDev.php line 41
at SmartyDev->fetch('/cms/page.tpl', null, 'layouts/layout-full-width.tpl') in FrontController.php line 655
at FrontControllerCore->smartyOutputContent('/cms/page.tpl') in FrontController.php line 639
at FrontControllerCore->display() in Controller.php line 221
at ControllerCore->run() in Dispatcher.php line 366
at DispatcherCore->dispatch() in index.php line 28

One thing that i have observed while debugging it is that when using default language inside display() function of FrontendController.php value of $this->template passed to $this->smartyOutputContent($this->template) is set to index.tpl and after switching language it is set to /index.tpl. If i manually set $this->smartyOutputContent('index.tpl') page works for both languages. So it seems that the problem is leading slash added to template name after language is switched to English.

 

The problem exists for any template that Smarty tries to load when shop is switched to non default language:

 

Unable to load template file '/cms/page.tpl'

Unable to load template file '/customer/authentication.tpl'

 

etc.

 

Any idea why this problem might exist here?

 

PrestaShop 1.7.0.5

PHP 7.1 or 7.0

Nginx

 

Link to comment
Share on other sites

Weird. It works fine on my XAMPP installation with PHP 7.0.13. I have 12 languages installed and no problems when switching between them. I installed PrestaShop with English though and then installed the other languages. Maybe you can reinstall in English and then add Polish?

 

You can post a bug report on the Forge.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...

Hi,

 

We had the same problem and fixed it in Prestashop 1.7

It's in the file: /classes/Smarty/TemplateFinder.php

if (is_file($dir.$locale.DIRECTORY_SEPARATOR.$tpl.$this->extension)) {
    // return $locale.DIRECTORY_SEPARATOR.$tpl.$this->extension;
    return $locale.$tpl.$this->extension;
}

By changing the language PS is adding a extra slash.
In that case the theme-files cannot find.

 

Kind regards,

 

Team DORST communicatie

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

In 1.7.1 this problem still exist, also in newest version 1.7.2

Fresh install on XAMPP and debian apache

 

 

and

$dir.$locale.DIRECTORY_SEPARATOR.$tpl 

this outputs:

string(73) "C:\xampp\htdocs\prestashop_171\PrestaShop/themes/classic/templates\\index"

double slashes before index

 

spcifically:

$locale

is empty and $dir outputs: "C:\xampp\htdocs\prestashop_171\PrestaShop/themes/classic/templates\" and then again is DIRECTORY_SEPERATOR

 

 

 

it works correctly when return looks like this:


return $dir.$locale.DIRECTORY_SEPARATOR.$tpl.$this->extension;

OR

return $tpl.$this->extension;

OR

return $dir.$tpl.$this->extension;

OR

return $locale.$tpl.$this->extension;

any help how to correct this without editing core files? :)

 

or maybe it's bug and there is just missing $dir in return in front of line 57

return $locale.DIRECTORY_SEPARATOR.$tpl.$this->extension;
Edited by azmaer (see edit history)
Link to comment
Share on other sites

  • 2 months later...
  • 4 months later...
On 15/06/2017 at 3:05 PM, dorstcom said:

Hi,

 

We had the same problem and fixed it in Prestashop 1.7

It's in the file: /classes/Smarty/TemplateFinder.php


if (is_file($dir.$locale.DIRECTORY_SEPARATOR.$tpl.$this->extension)) {
    // return $locale.DIRECTORY_SEPARATOR.$tpl.$this->extension;
    return $locale.$tpl.$this->extension;
}

By changing the language PS is adding a extra slash.
In that case the theme-files cannot find.

 

Kind regards,

 

Team DORST communicatie

it worked for me. thank you !!!

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...