Upgrade from smarty 2 to smarty 3 & 4

Author
Gregory
Publication
04/08/2023
04/08/2023
Update
04/13/2023
Rating
0.0 (0 vote)
Level
Normal
Upgrade from smarty 2 to smarty 3 & 4

Upgrade from smarty 2 to smarty 3 & 4 Since XOOPS 2.5.11-RC1 smarty 3 replaces smarty 2 and this can cause several problems on your website.
This tutorial will allow you to correct the errors that prevent your website from working properly.


A number of warnings may appear, these are not related to the smarty version but to the php version. This page is therefore not really related to the transition to smarty 3 but it is interesting to take advantage of this tutorial to explain how to remove these warnings.

For this kind of warning:

Avertissement: Undefined array key "statut" dans le fichier /xoops_data/caches/smarty_compile/ca10e9d0_xmnews_cp_transition_default^b54d6c404c41406c1d4faddd394cf658fd4bf489_0.db.xmnewsadmincategory.tpl.php ligne 59

Avertissement: Attempt to read property "value" on null dans le fichier /xoops_data/caches/smarty_compile/ca10e9d0_xmnews_cp_transition_default^b54d6c404c41406c1d4faddd394cf658fd4bf489_0.db.xmnewsadmincategory.tpl.php ligne 59

It is a bit more complex to find the error line because the warning indicates a cache file, so we will not have the exact error line which is, in this case, in the xmnews_admin_category.tpl


Corrections

If we go back to the warnings presented above, we only need to deal with the first one, "Undefined array key" :

Avertissement: Undefined array key statut in the file /xoops_data/caches/smarty_compile/ca10e9d0_xmnews_cp_transition_default^b54d6c404c41406c1d4faddd394cf658fd4bf489_0.db.xmnewsadmincategory.tpl.php line 59

The "statut" variable does not seem to be defined !
Just open the template xmnews_admin_category.tpl and search for the "statut" variable with the search tool.
The problematic code is:

<th class="txtcenter width5"><{$statut}></th>

To correct it, you have to define if it is a character string that is expected or a logical value.

  • If it's a character string, the code is modified like that:
    <th class="txtcenter width5"><{$statut|default:''}></th>

  • If it's a logical value, the code is modified like that:
    <th class="txtcenter width5"><{$statut|default: false}></th>