smarty icon indicating copy to clipboard operation
smarty copied to clipboard

Check compatability of reset, current, end, prev, and next in v5

Open wisskid opened this issue 1 year ago • 4 comments

Smarty v4 has special handling for reset, current, end, prev, and next in certain contexts. Check if behavior is consistent in v5.

wisskid avatar Apr 07 '24 12:04 wisskid

I want to upgrade from Smarty v4.5.3 => to v5.* in my PHP Framework https://emvicy.com/ on branch 2.x (https://github.com/emvicy/Emvicy/tree/2.x) and Smarty in v5.4.0 gives me this kind of error.

example

<code>
  /* array $aToolbar.aPathParam */
  {if true === empty($aToolbar.aPathParam)}
	  ...true....
  {else}
	 ...false...
  {/if}
</code>

error

Syntax error in template "string: [..]  on line 287 
"{if true === empty($aToolbar.aPathParam)}" unknown modifier 'empty'

I could not find any help on this specific topic yet (looked after also in https://smarty-php.github.io/smarty/stable/upgrading/#removed-smarty-api-methods)

So - How to handle or rewrite those kind of template code to get it work in Smarty 5 ?

gueff avatar Aug 18 '24 12:08 gueff

Please see https://smarty-php.github.io/smarty/stable/upgrading/#using-native-php-functions-or-userland-functions-in-your-templates

wisskid avatar Aug 18 '24 18:08 wisskid

Thank you for your answer, but unfortunately it doesn't really help me. I had already read that native php functions are no longer supported and that plugins should be registered instead (and I'm not happy about that).

I am very familiar with the use of plugins etc. in Smarty. The question I am asking is a bit different.

I do need such expressions as shown below in templates. How can or must this logical expression be noted in a Smarty template in the future:

formerly

{if true === empty($aVar)} ... {/if}

future ?

{if true === ($aVar|emptyModifier)} ... {/if}

I had not found anything about this. Sorry for my perhaps unclear previous formulation.

gueff avatar Aug 20 '24 07:08 gueff

You shouldn't have to change your templates at all.

wisskid avatar Aug 22 '24 07:08 wisskid