smarty

Show $params array('{item}' =>…)

自古美人都是妖i 提交于 2019-12-13 01:24:40
问题 Need some help. Have this code in PaymentModule.php in Prestashop: $params = array( '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), '{voucher_num}' => $voucher->code, '{firstname}' => $this->context->customer->firstname, '{lastname}' => $this->context->customer->lastname, '{id_order}' => $order->reference, '{order_name}' => $order->getUniqReference() ); I use $params['firstname'] for showing customer firstname and get nothing. I insert

shorten smarty if statements

女生的网名这么多〃 提交于 2019-12-13 01:15:54
问题 I have a smarty if statement as follows: <{if $page->getURLName() eq 'big-issues' or $page->getURLName() eq 'polls' or $page->getURLName() eq 'what-we-do' or $action eq 'events' or $action eq 'blogs' or $action eq 'news'}> I have to compare the same statements several time in the template. And its really tedious to ugly to repeat this statements several times. I know I can cache a statements and reuse it many times but I was looking if its possible to do something like this: <{if $page-

How to call a php function inside a smarty .tpl file?

为君一笑 提交于 2019-12-12 11:00:03
问题 Hi i have written a function in .php file. i.e. public static function getCategories($id_lang = false, $active = true, $order = true, $sql_filter = '', $sql_sort = '',$sql_limit = '') { if (!Validate::isBool($active)) die(Tools::displayError()); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category` WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)($id

How can I increment a Smarty variable?

懵懂的女人 提交于 2019-12-12 08:22:04
问题 I am not usually a Smarty guy, so I'm a bit stuck. I want to echo the index of an array, but I want to increment it each time I echo it. This is what I have... <ul> {foreach from=$gallery key=index item=image} <li> <img src="{$image}" alt="" id="panel-{$index++}" /> </li> {/foreach} </ul> It doesn't work. Is the best way to do this to pre-process the array before handing it to Smarty? Is there a way I can do this using Smarty? 回答1: You can do something like the following: <ul> {foreach from=

how to use Smarty better with PHP?

馋奶兔 提交于 2019-12-12 07:15:26
问题 I found that using Smarty with PHP, sometimes extra time will need to be used for 1) using quite different syntax than PHP itself 2) need to check small cases, because documentation doesn't give finer details, such as for "escape" http://www.smarty.net/manual/en/language.modifier.escape.php it doesn't say escape:"quotes" is for double quotes only or for single quotes as well, so you need to write code to test it. Also for the case of escape:"javascript" -- can't tell exactly what and how it

Dynamics variables in smarty in loop

删除回忆录丶 提交于 2019-12-12 05:15:06
问题 How can i generate dynamics variable names in smarty? I trying using {$item.schedule.d{$i}} to generate something like this {$item.schedule.d1}, {$item.schedule.d2}, ... 回答1: You can do this that way: In PHP: $items = array(); $items['schedule']['d1'] = 'D1'; $items['schedule']['d2'] = 'D2'; $items['schedule']['d3'] = 'D3'; $smarty->assign('items',$items); $smarty->display('index.tpl'); In index.tpl : {$data = [1,2,3]} {foreach $data as $value} {$items.schedule["d{$value}"]}<br /> {/foreach}

Smarty is not choosing the correct templates to display

瘦欲@ 提交于 2019-12-12 05:02:33
问题 I was working on a website yesterday and all was well. I was porting it to use Smarty. I had one last page to change which didn't require any testing since the Smarty template file didn't really do much. I saved my work, closed everything out, and left. Earlier today, I checked the site and found that it has gone haywire. It is displaying an incorrect template for all but one page. I never changed anything with my server setup so that can't be the problem. Pages that had previously worked

Call smarty variable from html instead of php

霸气de小男生 提交于 2019-12-12 04:55:19
问题 HTML CODE: <html><body> {section name=a loop=$items} {$items[a].title} {include file="/directory/showstuff.html" video=$items[a]} {/section} </body> </html> PHP CODE: $pid = '12'; $items = $cbvid->get_channel_items($pid); assign('items',$items); This is perfectly working fine, with the integer 12 being my php code. However, I wanted to add the integer 12 and call it from the html code, but it didn't work. I tried: <html><body> {section name=a loop=$cbvid->get_channel_items(12)} {$items[a]

Smarty cache site properties in database

◇◆丶佛笑我妖孽 提交于 2019-12-12 03:06:07
问题 I am going to build a site that have dynamic content (properties as title, url, etc) in the database. I guess it would be very unneccerary to query everything out and assign the variables, everytime, so I've read about caching. I use Smarty template, system. include('libs/Smarty/Smarty.class.php'); $smarty = new Smarty; $smarty->setCaching(true); if (!$smarty->isCached('index.tpl')) { //query here and assign.. $smarty->assign('title', 'Test'); } $smarty->display('themes/simple/index.tpl');

CodeIgniter not working with multiple level subfolders for both controllers and views

我怕爱的太早我们不能终老 提交于 2019-12-12 02:43:58
问题 I am working in Codeigniter with smarty templates. Problem is that if i go about 2nd subfolder in view or controller, the Codeigniter stops working... e-g here application/controllers/main.php - works application/controllers/admin/dashboard.php - works application/controllers/admin/manageUsers/ListUsers.php - not working I have searched the web, and they said that i can work with routes, which might do work with controller.. but it is views that i am concern of.. i mean admin views should go