Questions tagged [smarty]

Smarty is a templating engine for PHP. It allows for easy separation of application logic and display code, as well as simplifying reuse of templates.

Overview

Smarty templating engine for PHP lets easily separate application logic and presentation, the first being in PHP code and the other generally, but not always, in HTML. That way a separation of PHP and HTML code is encouraged.

Currently two versions of Smarty are maintained for legacy purposes that is compatible with PHP 7.2, and that is compatible with PHP 7.3 and PHP 7.4.

As of April 13th 2020, current Smarty releases are 3.1.35 and 2.6.31

Example

PHP script (example.php) :

require_once('../smarty/Smarty.class.php');
$se = new Smarty();

$se->assign('pi', 3.14159);
$se->assign(array(
    'title' => 'Hello World !',
    'today' => date('d/m/Y'),
));

$se->display('example.tpl');

Template (example.tpl) :

<!DOCTYPE html>
<html>
  <head>
    <title>Smarty example</title>
  </head>
  <body>
    <p>{$title}</p>
    <p>Pi value : {$pi}</p>
    <p>Today is : {$today}</p>
  </body>
</html>

Links:

4490 questions
1
vote
3 answers

How do i change only the Copyright of my Prestashop page?

I couldn't find anything about changing my Copyright of the footer. That little part that says: "A SHOP © 2014. All Rights Reserved." I just need to change that little part having it to say "B-divine © 2014. All Rights Reserved." I looked at…
ruby0ne
  • 31
  • 1
  • 5
1
vote
4 answers

Include other .tpl in a .tpl file Prestashop

I'm usinh a Prestashop 1.5.4.1, and I would like to call a module in other module (precisely I need to use slider module just above the home featured products). I tried to call it via include file='../directory/module.tpl' but always I get only…
kacper
  • 370
  • 2
  • 6
  • 13
1
vote
1 answer

{$link->getPageLink("$order_process.php", true)} not working outside blockcart template

I'm trying to add a second link to the order process outside of the blockcart module, but when I use {$link->getPageLink("$order_process", true)|escape:'html'} to generate the URL, it gives the following invalid…
user1280853
  • 1,079
  • 5
  • 14
  • 23
1
vote
0 answers

In Smarty Jquery datepicker is not working in IE only

In Smarty , below code not working in IE $("#from").datepicker({ dateFormat: 'dd/mm/yy', altFormat: 'yy-mm-dd', altField: '#from_alt', changeMonth: true, changeYear: true, beforeShowDay: nationalDays, onSelect:…
Aravinthan
  • 487
  • 1
  • 4
  • 7
1
vote
1 answer

Smarty print json array

Am new to Smarty, i have a json array, my json array looks like following format [ { "id": "1", "venue": "Test Venue1", "game_date": "0000-00-00 00:00:00" }, { "id": "2", "venue": "Test Venue 2", …
Dibish
  • 9,133
  • 22
  • 64
  • 106
1
vote
4 answers

Mirroring user inputs in a form, Is there an alternative way to do this?

I intend to "bring back" some information about a user in a form, so I have to place that info into the right inputs. Some are in a select structure. I want to select the right option from that select structure, and for that I do like this:
Limon
  • 1,772
  • 7
  • 32
  • 61
1
vote
1 answer

captcha in smarty doesn't work

I have this problem with smarty, I tried to add a captcha in smarty but I can't see the way of make it work, basically the error comes when i try to show the captcha image, in a normal php file I could embed this php script:
user2957058
  • 270
  • 5
  • 16
1
vote
1 answer

encoding increase the size string, but decode don't reduce it

I'm sending an string via an url. The string I wrote is : "tasse(s)", size : 8 When i transmit it from the url, it encodes the string, so it's like that : string(16) "tasse(s)" and If I get more info, its : string(16) "tasse(s)" So,…
Choubidou
  • 351
  • 2
  • 4
  • 17
1
vote
1 answer

Smarty PHP templates, mod rewrite changing URL but not page

I've rewritten this question now as I don't think the problem is to do with the URL rewrite. I'm building a site with PHP and Smarty and using fairly common url rewriting using apache's mod rewrite. Locally, if I visit: example.com/search/?q=test, I…
Pete
  • 4,542
  • 9
  • 43
  • 76
1
vote
1 answer

config files with php variables smarty

In my php file to send emails I would like to use smarty config variables however currently I have to cut them This is part of the PHP file: PHP $messagecontent .= "

bla bla bla bla $username xxxx $myitemname

When you…

Athanatos
  • 1,089
  • 6
  • 15
  • 32
1
vote
1 answer

Twig & Smarty: object from JSON file

I'm learning both Twig and Smarty and I didn't find an answer for my question for both of them. The question is: is there some built-in way to read variable's value from separate JSON file? I'll use Twig for my examples. OK, this is regular Twig…
nyan-cat
  • 610
  • 5
  • 19
1
vote
0 answers

Admin Login Load() SMARTY can't get POSTs

first I have to use PHP4 and SMARTY2. Yep I know it is very bad :-/ but we're unable to upgrade cause the existing systems need that environment... :@ I want to code a admin login with jquery's load and php. There is a 3 part Login cause of the tpl…
the_X
  • 36
  • 4
1
vote
3 answers

How to assign and display data in smarty template received from AJAX?

I'm not able to assign and display the data in a smarty template. I receive the data from the AJAX. Also I'm not able to show the loader image until the page-data loads completely. Can anyone help me please? PHP Code:(match_question.php)
user2838698
1
vote
2 answers

get data from POPUP window back to Parent(SMARTY)

my popup gets data from Database where the user can chose from. now can somone explain me how i can get submitted data(array) from my popup window back to my PARENT Form and after that back to "PARENT PHP" ?:X i already found a way using…
1
vote
1 answer

How do I recursively nest smarty {foreach} loops while still being able to use {$smarty.foreach..first/last}?

I have a Smarty template file in which I'm looping over hierarchical data represented by nested arrays. The child data is represented exactly the same way as the parent data, so I wanted to recursively {include} the Smarty template to render…
Michael Moussa
  • 4,207
  • 5
  • 35
  • 53