Jump to content

Theme Template Issue Following Upgrade (1.6 to 1.7) - Template Not Found


Recommended Posts

I recently manually upgraded a site from 1.6 to 1.7.  There was a laundry list of complications I dealt with (including that the theme work had all been done in default_bootstrap and was thus essentially lost/had to be redone) but only one, at present, that continues to vex me.  Specifically, when I attempt to view product categories on the main shop I am presented with a 500 error.

So, if I went to https://<shop-url>/<category-name> I would get a 500 error.

Turning debug mode on reveals the full extent of the error as:

[PrestaShopException]

No template found for [PROJECT_WEB_ROOT]/themes/[PROJECT_THEME_DIRECTORY]/category.tpl
at line 73 in file classes/Smarty/TemplateFinder.php

68.                     return $tpl;
69.                 }
70.             }
71.         }
72. 
73.         throw new PrestaShopException('No template found for ' . $template);
74.     }
75. 
76.     private function getTemplateHierarchy($template, $entity, $id)
77.     {
78.         $entity = basename($entity);

Now, I went into the Smarty engine and added a few debugging lines to see what's what (hence why the exception isn't being thrown on line 68 as it ordinarily would), and here's where I found out why it can't find the template.  It's looking in the following three paths:
 

[PROJECT_WEB_ROOT]/themes/[PROJECT_THEME_DIRECTORY]/templates/en-US/[PROJECT_WEB_ROOT]/themes/[PROJECT_THEME_DIRECTORY]/category.tpl.tpl

[PROJECT_WEB_ROOT]/themes/[PROJECT_THEME_DIRECTORY]/templates/[PROJECT_WEB_ROOT]/themes/[PROJECT_THEME_DIRECTORY]/category.tpl.tpl

[PROJECT_WEB_ROOT]/public_html/themes/[PROJECT_THEME_DIRECTORY]/templates/[PROJECT_WEB_ROOT]/themes/[PROJECT_THEME_DIRECTORY]/category.tpl

Above omitting specific directories in lieu of bracketed placeholders.

Essentially, it appears that there's a full superfluous file system path being fed into the template finder.  Like, rather than appending something like [templatename].tpl, it appends [full-path-to-template-plus-template-name].tpl, when it ought not.

Does anyone know what could cause this and where to look and adjust to correct it?  I'm not exactly familiar with Prestashop specifically, so tracing it back and finding a root cause is proving really time-consuming.  I hope that someone in this community knows more about the software and can give me pointers as to where to look to find the source of this misbehavior.

Additional information if it helps - this only seems to occur (I say "seems" because I haven't done a full accounting, but have definitely found lots of places it doesn't occur) for category view.  So Smarty is being fed the correct template file paths under other circumstances.

Link to comment
Share on other sites

I dug a little deeper and progressed through the stack trace.  Ultimately I found the issue, but not the cause of the issue.

Instead of the template value for categories being something sane like "categories", it is the full file system path including categories, plus a TPL extension.  So when Smarty helpfully prepends various possible directory structures to the template value it's effectively duplicating the file system path to some degree no matter which prepend it tries, and then guaranteed duplicating the .tpl extension when it appends that at the end.

Any idea what guides Prestashop's basic template values for a given section?

Link to comment
Share on other sites

I sorted it out - I ended up zeroing in on CategoryController.php as the root of all evil.  Further investigation revealed it was structurally very different from the other controllers - leading me to suspect it was a now-superfluous (and downright cancerous) relic of the 1.6 codebase that looked upon its new 1.7 brethren with jealousy and - dare I say - intent to do harm.

I examined the archive containing the original 1.7 install files I downloaded.  Lo and behold, no CategoryController.php in /controllers/front.

So on a whim (and after backing it up, naturally) I deleted CategoryController.php entirely, and category view started displaying properly immediately.

The lesson I'm taking away from this, pending further input from more Prestashop savvy folks who could clarify the wisdom of my conclusions, is thus:

Don't just worry about what an upgrade adds or updates - also worry about what an install doesn't remove.

It looks like 1.7 is made unstable under certain circumstances (such as, in my case, category view) by the mere presence of certain 1.6 files, files that ought to be removed in addition to files being added/overwritten.  Maybe this is only a danger to folks who upgrade manually.

I'm seeing a few other controllers (ParentOrderController, BestSalesController, &etc...) that also appear to pre-date the 1.7 codebase.  Should I remove them as well, and, as a follow-up, is there a definitive guide that covers what superfluous/incompatible 1.6 files need to be removed following a manual upgrade to avoid issues?

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 3 years later...

THANK YOU KBARSOTTI!!!

Oh my gosh!  I have been searching for DAYS to the solution to my 500 Server Error!  I am not a techie at all ... I know just enough to get myself into trouble, but your solution FIXED my problem.  Thank you so much for your help!

: D

Link to comment
Share on other sites

  • 2 weeks later...

Dear all,

 

I have 0 experience programming. I upgraded my shop to the latest version , then tried to add the new product module to the main page because it was gone and now nothing works. No back-office at all. just errors. Any help please?

 

SmartyException

in vendor\smarty\smarty\libs\sysplugins\smarty_template_compiled.php (line 96)

    public function render(Smarty_Internal_Template $_template)

    {

        // checks if template exists

        if (!$_template->source->exists) {

            $type = $_template->source->isConfig ? 'config' : 'template';

            throw new SmartyException("Unable to load {$type} '{$_template->source->type}:{$_template->source->name}'");

        }

        if ($_template->smarty->debugging) {

            if (!isset($_template->smarty->_debug)) {

                $_template->smarty->_debug = new Smarty_Internal_Debug();

            }

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