Questions tagged [smarty3]

Smarty is a template engine for PHP. It enables programmers and web-designers to implement the MVC architecture pattern. The templates created can be re-used very easily.

Smarty3 is the most up-to-date branch of Smarty template engine. It requires PHP 5.2+

Last Smarty3 version is 3.1.31 and was released on Dec 14, 2016

Links

373 questions
20
votes
1 answer

Importing class without namespace to namespaced class

I have a some class, it include Smarty, but my class use namespace test, Smarty don't use namespaces. How include Smarty, without writing namespaces into smarty files (it has many system plugins) import "smarty/Smarty.php" class…
TROODON
  • 1,175
  • 1
  • 9
  • 17
8
votes
2 answers

How to parse/decode JSON object in smarty template?

I have the following code in my template file: {foreach from=$items item=entry}
    {$entry->nb_persons|@print_r}
  
{/foreach} The output is (json…
cookie669
  • 83
  • 1
  • 1
  • 3
7
votes
1 answer

Smarty registerPlugin function as argument

In Smarty, it is possible to register an plugin in this way: $smarty->registerPlugin("function","date_now", "print_current_date"); function print_current_date($params, $smarty) { if(empty($params["format"])) { $format = "%b %e, %Y"; } else…
tiefenb
  • 732
  • 3
  • 16
  • 32
7
votes
1 answer

Calculate the difference between two dates in smarty 3 template prestashop

I have to calculate a sale end time relative to today, I have the sale end time variable in this format {%d/%m/%Y %H:%M:%S} e.g.:(31/07/2016 18:27:58). What I'm trying to do is to show ends: 8 days 06:10:29. I can't use php code in the template…
no_dir_rahou
  • 81
  • 1
  • 7
6
votes
1 answer

Is there a i18n/translation solution for Smarty?

I'm developing a PHP-based application that requires internationalization (i18n) support. I'm using Smarty 3 as a template solution (and TinyMVC as the framework), and although I've been using it for small projects before (back in the days of Smarty…
Jimmie Lin
  • 2,205
  • 2
  • 23
  • 35
6
votes
3 answers

error: Database not selected

I'm stuck with this issue: No database selected. I roll over the same problems posted here, but after hours of reading I can't figure out why the database is not selected. I created a database job and a table job. I run the script with WAMP server.…
Nikolay
  • 121
  • 5
6
votes
1 answer

How can Smarty 3 be Used with Zend Framework 2?

I used PHP5 a long time ago and am presently trying to refresh my knowledge and augment it with knowledge of Zend Framework 2 and Smarty 3 for a possible project. I'm currently trying to figure out how to use Smarty 3 as a replacement/supplement to…
Brian Kessler
  • 2,187
  • 6
  • 28
  • 58
5
votes
2 answers

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

I'm trying to migrate from my old PHP 5.4.45 + Smarty 2.6.28 to my new PHP 7.2.25 + Smarty 3.1.33. I'm tuning some small pieces of code, it works in most of webpages, but suddenly it stop working in some PHP pages, returning the following error…
Hookstark
  • 1,097
  • 3
  • 11
  • 23
5
votes
1 answer

$smarty.current_dir value when called from extended template

My code is as follows: content.tpl: {* Smarty *} {extends file='PageContentLayout.tpl'} PageContentLayout.tpl {* Smarty *} {block name="file_name"}

{$smarty.current_dir}

{$smarty.template}

{/block} {block…
cartbeforehorse
  • 3,045
  • 1
  • 34
  • 49
5
votes
4 answers

how to use html tags in prestashop's smarty translations?

I can't find a solution. What I've got to do is translate this: se stai inserendo un indirizzo per consegna all'interno dell'area EXPO into this: If your delivery address is in the EXPO area If I…
Luca Reghellin
  • 7,426
  • 12
  • 73
  • 118
5
votes
1 answer

Smarty: get the current physical file path

In Smarty, is there a way to retrieve the current physical path of the template file? I'm looking for the Smarty equivalent of the PHP __FILE__ super-variable. (I'm sure that this question must have been asked before, but I can't for the life of me…
cartbeforehorse
  • 3,045
  • 1
  • 34
  • 49
5
votes
3 answers

strip spaces from string using smarty

I am new to smarty. I want to know how to remove all white-space characters from a given string in Smarty? I have a string like "this is my string". The output should be "thisismystring". How can I do this?
vandu
  • 196
  • 1
  • 3
  • 17
4
votes
2 answers

{if}{else} do not work properly in smarty

I have following smarty code on my template {capture name="diff"} {datediff timestamp=$data_base.updated_date} {/capture} {$smarty.capture.diff} | {$smarty.const.UPDATE_BLOCK_SECONDS} {if $smarty.capture.diff >…
Prakash
  • 2,749
  • 4
  • 33
  • 43
4
votes
1 answer

How does smarty cache work? How does it know when to cache?

What makes smarty decide if the cache it has is sufficient or if it needs to recreate it? Will the $_REQUEST do? Or all globals including cookies, session and etc... Is index.php and index.php?task=home have the same cache, what about cookies and…
Neo
  • 11,078
  • 2
  • 68
  • 79
4
votes
1 answer

Check whether a string contains substring with Smarty

I'm having a bit of a problem with my email-templates. Shopware for some reason uses Smarty as a template language for their emails. My Problem now is that I have this email-template Tracking: {if $sDispatch.name == "DHL national" } …
tombjarne
  • 78
  • 1
  • 2
  • 5
1
2 3
24 25