Jump to content

Smarty 2 or Smarty 3


Aldeag

Recommended Posts

I use Prestashop 1.4.5.1 and after upgrading from 1.3.6 I see many bugs.

But this topic is only to question about the use of Smarty.

I don´t know nothing about programming.

I suppoussed that 1.4.5.1 was going to be compatible with Smarty 3 as Presta 1.5 I think will only work with Smarty 3

 

But if I check to use Smarty 3 instead of 2 I get this problem in the main page of the Front Office:

 

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/menu_tree.tpl" on line 23 "{foreach from=$item.childrens item=item name=menuTreeChildrens}" item variable 'item' may not be the same variable as at 'from'' in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:431 Stack trace: #0 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_compile_foreach.php(40): Smarty_Internal_TemplateCompilerBase->trigger_template_error('item variable '...', 23) #1 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(284): Smarty_Internal_Compile_Foreach->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_template in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 431

 

So I have to use Smarty 2

Is it normal?

Link to comment
Share on other sites

Sounds like your theme may not be smarty 3 compatible (as a novice I am making a quick guess) - but looking at your site you have used the default theme? I guess you have switched it until you find the fix - which theme are you having the problem with?

 

You can check your theme here http://validator.prestashop.com/?page=guide

 

If you theme fails to validate - then Yes it is normal to only work with Smarty 2. You should consider updating the theme or making a new one to Smarty 3 standards as Prestashop is moving on with Smarty 3 and you will have further issues when you upgrade in the future.

Link to comment
Share on other sites

Yes smarty syntax has evolved between version 2 to 3.

 

In order to make templates within your theme compatable with smarty3, it usually suffise to adapt the syntax in include and assign

Example:

{include file=$tpl_dir./scenes.tpl scenes=$scenes}

Should be converted to:

{include file="$tpl_dir./scenes.tpl" scenes=$scenes}

 

Also, you should not forget to copy thoses new templates that did not exists prior 1.4, which is the case weither you use smarty v2 or v3:

product-compare.tpl

products-comparison.tpl

store_infos.tpl

store.tpl

order-opc-new-account.tpl

restricted-country.tpl

guest-tracking.tpl

category-cms-tree-branch.tpl

order-opc.tpl

 

It worth also taking some time to convert product.tpl so it take care of the new tax rules and catalog mode.

 

Best,

(d)oekia

  • Like 1
Link to comment
Share on other sites

I recommend you to install a fresh prestashop 1.4.5. Upgrading offen occurs problems.

A totallly false statement.

I have upgraded hundreds of shop with not a single problem.

When problem occurs they are related to core/database mod or theme inconsistencies

Link to comment
Share on other sites

I quote my self. Seems that at least jbx_menu is not compatible with smarty 3. Or am I wrong?

 

I use Prestashop 1.4.5.1 and after upgrading from 1.3.6 I see many bugs.

But this topic is only to question about the use of Smarty.

I don´t know nothing about programming.

I suppoussed that 1.4.5.1 was going to be compatible with Smarty 3 as Presta 1.5 I think will only work with Smarty 3

 

But if I check to use Smarty 3 instead of 2 I get this problem in the main page of the Front Office:

 

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/menu_tree.tpl" on line 23 "{foreach from=$item.childrens item=item name=menuTreeChildrens}" item variable 'item' may not be the same variable as at 'from'' in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:431 Stack trace: #0 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_compile_foreach.php(40): Smarty_Internal_TemplateCompilerBase->trigger_template_error('item variable '...', 23) #1 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(284): Smarty_Internal_Compile_Foreach->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_template in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 431

 

So I have to use Smarty 2

Is it normal?

Link to comment
Share on other sites

tweak a bit the syntax I think {foreach from=${item.childrens} item=item name=menuTreeChildrens} will do

 

Should I find that line, delete it, substitute for other? What?

I don´t know much about programming.

Maybe others reading this know less than me. Can you be more explicit? Thanks!!

Link to comment
Share on other sites

mode: !!!

 

In your file /modules/jbx_menu/menu_tree.tpl you have this line:

{foreach from=$item.childrens item=item name=menuTreeChildrens}

try to replace it with this:

{foreach from=${item.childrens} item=item name=menuTreeChildrens}

 

Clear your smarty cache, test

Link to comment
Share on other sites

mode: !!!

 

In your file /modules/jbx_menu/menu_tree.tpl you have this line:

{foreach from=$item.childrens item=item name=menuTreeChildrens}

try to replace it with this:

{foreach from=${item.childrens} item=item name=menuTreeChildrens}

 

Done!

 

Clear your smarty cache, test

 

How I do that?

Link to comment
Share on other sites

Empty both.

 

Module enabled and in front office I see a white page with this message:

 

 

Notice: Undefined variable: title in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/menu.class.php on line 265

 

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/menu_tree.tpl" on line 23 "{foreach from=${item.childrens} item=item name=menuTreeChildrens}" - Unexpected "."' in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:431 Stack trace: #0 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templateparser.php(2855): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templateparser.php(2920): Smarty_Internal_Templateparser->yy_syntax_error(56, '.') #2 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(51): Smarty_Internal_Templateparser->doParse(56, '.') #3 /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tienda in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 431

Link to comment
Share on other sites

Question is this version of the jbx_menu a legal one?

If yes, you may consider upgrading to latest version which correct the error.

 

Since this a free licensed module, the correction is this:

In your file /modules/jbx_menu/menu_tree.tpl you have this line:

{foreach from=$item.childrens item=item name=menuTreeChildrens}

try to replace it with this:

{foreach from={$item.childrens} item=item name=menuTreeChildrens}

Link to comment
Share on other sites

Now I see my page, but I get this message on top of the page.

 

Notice: Undefined variable: title in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/menu.class.php on line 265

 

The menú is empty. It doesn´t saved my settings

And it is the original. Version 2.6.4

I imported the module from my last update. It was Prestashop 1.4.5.1

Maybe I have to import some other settings

Link to comment
Share on other sites

Ok, edit the file /modules/jbx_menu/menu.class.php add a line betwwen 182 and 183, type in the following code:

if (!isset($results) || !is_array($results)) $results = array();

 

Then report the bug to Julien

 

With that line added I don´t see the error message, but I don´t see the jbx_menu either. It dissapears.

 

I will report Julien.

Link to comment
Share on other sites

That is pretty odd because I just take the jbx_menu 2.8.4 , pristine, it runs like a charm on all my different PS. And on my staging system I have some setting that trap on any coding errors, and it went silent.

 

You mention 777? Is this on a hosting service? Sometimes 777 is not allowed (ie OVH forbid this use - max perm is 707 group should always be clean). In case, uninstall the module, physically remove it, clear your cache (server).

 

How did you installed it by the way? Thru the panel directly or FTP? Usually I prefer panel mode even doo that is not quite good some times. Try reinstall then.

 

Hope this time we will go somewhere.

Link to comment
Share on other sites

I delete the module with my FTP (Cyberduck on a Mac) and the changes we made inside in /modules/jbx_menu/menu.class.php

Emptyed cache

Uploaded module again with Cyberduck. Set permisions to 777 (Owner, Group and Others can read, write and execute) recursively.

In the back office I get this error

 

Warning: file_put_contents(/var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/config.xml) [function.file-put-contents]: failed to open stream: Permission denied in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/classes/Module.php on line 1114

 

In the front office I get this on top of my page:

 

Warning: Invalid argument supplied for foreach() in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/menu.class.php on line 183

 

If I add the line you comment

if (!isset($results) || !is_array($results)) $results = array();

I get the same problems: error line on top dissapears and JBX menu dissapears also.

 

If I delete the line, the menu appears and the error message also appears

 

If I want to add items inside the module it says "Upgrade succesfull", but the menu keeps empty...

I only see one object named "Link" but no other adds

I deleted that object and the message is:

ok2.png Deletion successful

List of Objets

Your menu is full!!

Link to comment
Share on other sites

Warning: file_put_contents(/var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/modules/jbx_menu/config.xml) [function.file-put-contents]: failed to open stream: Permission denied in /var/www/vhosts/aldeaglobaltarifa.com/httpdocs/tiendaweb/classes/Module.php on line 1114

 

Yes a permission problem.

Set write permissions recursively for the module dir (for all dir within modules btw)

Under a SSH terminal you can do such by chmod -R a+w <directory-holding-modules>

Once the permissions fixed, from the BO, uninstall / reinstall the module (reset)

 

BTW, 777 is for directories, while for files it is 666

Link to comment
Share on other sites

But in the instructions for installing/upgrading I can read:

 

If not, make sure that the folders' rights are properly configured: change

the access rights of the folders marked in red in the install/update tool,

directly on your FTP server (make a CHMOD 755 or 775, depending on

your hosting provider) then click the "Refresh these settings" button.

In order to perform a CHMOD, using your FTP client, find the folders that

have the wrong permission settings, right-click on each of them in order

to display their properties (or even better, their access rights), and tick

the boxes that are not yet ticked, until a refresh of the "System and

Permissions" page gives you only green folder.

 

I thought 755 or 775 were more restrictive than 777

Link to comment
Share on other sites

Yes on directory 755 means owner full rights (ftp user), group(read browse), everyone (read, browse)

On file the browse mean execute

The web server neads only read for displaying page, while during install/configuration it needs write to the folder and write on the file if it exists. Raison why I said recursive!

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for your interest Doekia. I´ve been out for holidays and, though I came in the forum a few times, I couldn´t check the FTP access which was on another computer I use for it.

Anyway, I got the solution today from other user in the spanish forum ("4webs.es") and seemed so simple I feel silly:

In Back Office, I restarted the module.

Don´t delete the first Item (Julien Breux (link)) It was the first thing I always did, and I don´t know if it´s a bug.

Then I can add the rest of the items.

Now I have the bar working :)

Link to comment
Share on other sites

  • 9 months later...

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