smarty

section with nest array in smarty

Array ( [0] => Array ( [0] => SimpleXMLElement Object ( [0] => Pop music ) [1] => SimpleXMLElement Object ( [0] => Rock music ) [2] => SimpleXMLElement Object ( ...

Find last element of an array with a certain property in smarty

I am looping through a nested array in smarty, and each element has a status of 'active' or 'inactive'. How can I detect the last element in the array that is set to active? example code: {foreach from=$steps item=step name=step} {if $step.status == 'active' && ????? } {/if} {/foreach} ...

How to assign an array within a smarty template file?

I was wondering if it was possible to assign an array to a variable within a Smarty template file? I have tried this {assign var='file' value = array('dir','doc','exe')} But when I print out the array it produces this: array(\'dir\',\'doc\',\'exe\') How can I stop Smarty escaping the array values? Thanks in advance ...

Reconfiguring PHP Mail() Smarty Contact Form

Hi, I'm using Prestashop as my ecommerce shopping cart and CMS solution and was having problems receiving emails sent via the contact form. I asked around and found the problem to be due to the fact that I need to assign the 'from' address as something from my domain (e.g. [email protected]) and the email entered by user to be a...

Method as target of {if} in Smarty

Is there a way to use a method call of an object as the target of a conditional in a Smarty template? As a concrete example, I have an object $user with a method loggedIn(). I want to use this method to show extra info if the user is logged in. I can assign the return value of this method to a temporary variable and use this as the tar...

Get Template Name - Smarty

I'm dealing with website is a mess and need to find out the template file that smarty is rendering. Is there a method on the smarty template object that I can call to get the current template file? for example echo $tplObj->getTemplate(); // echos "shop/templates/cart.tpl" ...

Jquery with SMARTY and JSON

table department(department_id, name) table category(category_id, department_id, name) I want to implement the idea that when i change department in drop down list, all categories will change according to the department value It 's my jquery script {literal} <script type="text/javascript"> $(document).ready(function(){ $('#departmen...

How to build url in smarty template?

In template I have two strings which I want to combine in one. {assign var="bigUrl" value="Search?searchFor=Member&{$searchUrl}"} To be able to use variable {$bigUrl} below in template, like this: <a href={$bigUrl}>Link</a> When I write mentioned assignment smarty compiler report error: syntax error: invalid attribute name: '=' ...

Smarty echo of array variable with "-" in its name

Hi, I have variable that in PHP controller looks like $data['content']['mods']['HTML-FORM-END']['html'] It is passed nicely in smarty, but when I try to show it any of these ways, it shows either 0 (assumes minus as operator and does some math), or says "unrecognized tag" {$data.content.mods.HTML-FORM-BEGIN.html} {$data.content.mods[...

How to generate year in Smarty?

How can i generate a select list with the given year till this year? i did this {assign var=thisyear value=$smarty.now|date_format:"%Y"} {if !$firstyear} {assign var=firstyear value="2003"} {/if} {if !$loop}{assign var=loop value=$thisyear}{/if} <select name='{$id|default:year}' id={$id|default:year} style='width:70px;'> {section na...

Smarty compressed template caching in memcached

Right now i use smarty caching and it stores cached template on disk, i have new caching handler(memcached handler) that will store cached template in memcached but i cant decide what compression to use and if i should use any? So im thinking of compressing it with gzcompress(level 9) before storing to reduce size but will it effect perf...

Eval Smarty Code inside a Smarty Template

Hi, is there a way to evaluate Smarty Code inside an existing Smarty template? For example, I may have the following construct: smartyTemplate.tpl <body> <div id="dynamicPart"> {$valueFromDatabase} </div> </body> Whereas the Smarty variable $valueFromDatabase contains another Smarty Template which I would like to be inserte...

PHP - lookup array contents with dot syntax

Does anybody see anything wrong with the following function? (Edit: no, I don't think anything is wrong, I am just double-checking since this will be inserted into a very common code path.) function getNestedVar(&$context, $name) { if (strstr($name, '.') === FALSE) { return $context[$name]; } else { $pieces = exp...

Obtaining POST variables in a template of eZ Publish

Hi, I have a form in a template (not a eZ generated form) which posts to another eZ page. How do I get the POST variables within the template? Thanks. ...

Why do almost all PHP framework use "<?php echo ... ?>"

The PHP short tag <?= $var ?> has been deprecated for a while. Almost all PHP frameworks use the long form <?php echo $var ?> (e.g., symphony, Yii, Kohana) Smarty is a famous PHP template engine which supports a shorter form {$var} Template engines (like Smarty) are easier for web designer Editing a template shows {$var} instead of sh...

smarty assign to array

$result = mysql_query("SELECT blog_title,body FROM blog WHERE post_id='$id' LIMIT 1") or die (mysql_error()); while ($line = mysql_fetch_assoc($result)){ $tasks[] = $line; $group = $tasks['blog_title']; $smarty->assign('view', $tasks); $smarty->assign('group', $group); //here the error.i want to assign blog_title to title $smarty->...

How to include javascript from a CDN source using smarty

How do you include Javascript from a CDN source using Smarty? We have code such as the following for including it from a file on the web server, but I want to include it from a CDN instead. {javascript file="prototype.js" priority=20} When I access the Smarty documentation at http://www.smarty.net/manual/en/ "javascript" cannot be ...

'click' observer in Prototype

I have a page which contains several divs (each with a unique ID and the same class, 'parent'). Underneath each "parent" div, is a div with class "child" and unique ID name -child. This DIV is upon page load empty. Whenever you click on a parent DIV, the following code is executed. $$('div.parent').each(function(s){ $(s).observe('c...

Integration of fckeditor in Social engine tepmplate

Hi all, I want to integrate FCK editor instead of text area filed in social engine .tpl file. Does Any one know ? How to integrate? ...

Is it possible to format a number to 2 decimal places with Smarty PHP

Hi, Is it possible to format a number to 2 decimal places with Smarty PHP? Thanks. ...