Upgrade smarty 2 to smarty 3/4
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
Important
It is likely that these warnings will become errors in future versions of PHP, so it is necessary to correct them!
The explanation on tempaltes on the previous page also applies to this page
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>