Вопрос

I am using Smarty 2.6.9 and I am finding that I experience issues with the following block of code.

Copyright © {$smarty.now|date_format:'%Y'} CRMPicco. All rights reserved

The date generated by Smarty seems to be random, sometimes it's 8780, sometimes it's 1872...as I say, completely random.

What I am finding is this seems to be an environmental issue too, as it works in my development environment (CentOS 5.6) but is broken in a testing environment. Now, I realise this would point to a config issue on the testing environment but I am using PHP date functions all through the codebase and if it wasn't working i'd soon know about it.

I appreciate I may get suggestions along the lines of "if PHP date function works then send that through to your Smarty template", but there must be a way to do it in Smarty too?

Is this a bug in Smarty or a config issue?

Это было полезно?

Решение

It's a somewhat-known configuration issue, caused by $smarty->plugins_dir not being set correctly (or some other problem preventing access to that directory).

date_format is the name of a Smarty plugin, but it's also the name of a PHP function. If Smarty cannot locate its plugin it falls back to calling the PHP function, which expects a completely different set of arguments. The resulting breakage is what you see.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top