smarty

smarty variables inside javascript

i am trying to use smarty variables inside javascript inside tpl http://pastebin.com/PXmy8jxf can you suggest me solution please update: http://pastebin.com/J4ibLz1m ...

append number to variable name and call it in a loop (php) (smarty)

Hi. I have a simple question. I need to append 1,2,3 etc to a variable name in smarty. The variables are $user1, $user2, $user3 etc. I use smarty to do a simple loop like this: {section name=user_info start=1 loop=$users} <tr> <td> User{$smarty.section.user_info.index} </td> // prints user1, user2, user3 etc ...

Smarty Templates PHP - Remove specific text from a string

I have the following code: {$product.name} This outputs all of our products, unfortunatly they are stored in the database as 'CompanyNameProductName'. I want to remove the string 'CompanyName' from the string $product.name How can I do this in PHP? ...

Smarty Templates - Return product info based on topic type

Im using the following code: {foreach from=$entries key=i item=topic} {if $topic.topic_style == problem} <li> <a href="topic.php?id={$topic.id}">{$topic.title}</a> </li> {/if} {/foreach} Which returns the topics which are all 'problem's. Its possible to tag a problem with a product, the system uses the Get Satisfact...

Smarty dealing with array

Im trying to view contents of array on the page: {foreach from=$entries key=i item=topic} {if $topic.topic_style == question} <li class="mail"> <a href="topic.php?id={$topic.id}">{$topic.title} </a> {$topic.tags} </li> {/if} {/foreach} $topic.tags is a...

Loop through two dimensional array with Smarty

Hey guys, I am trying to make the following loop work. Basically, I am trying to display the children as options. Why doesn't it work? The optiongroups are being displayed. And the arrays are constructed the right way. {foreach from=$tpl_parents item='row' key='i'} <optgroup label="{$row.NAME}"> {foreach from=$tpl_children....

How to sort this array ??

Hello, For the last 3 days, I have been trying to sort an array, but without success. I tried in the php file first and in the tpl file, but it was impossible for me to sort my array. Can you help me please ?? This is the structure of my array (thanks to the smaty debug tool !) : Array (5) attributes => Array (4) 23 => "1L" 24 =...

comparing a number with an array item in smarty

This is what I would like to do: I have assigned the following items: $smarty->assign('seats', $aantalStoeltjes); $smarty->assign('taken', $bezetArray); "seats" is the number of seats available. This is an array with only one item. The number 150 in this case but is dynamic. "taken" is the seats that are already taken and should not ...

Is it possible to fetch values using smarty, php, JQuery from another page ? [ No Cross-domains ]

Hello, I am working on smarty template files. core php of that template engine are encoded with ioncube. So I am restricted to get certain values on certain pages only. For Example, I get value of {$clientemail} only on clientareadetails.php on clientprofile.php value of {$clientemail} is null So, Is it possible to fetch values...

Is something wrong with wrapping whole Smarty templates in {strip} tags?

I want to keep my templates tidy and nicely intented but would like to deliver only very compact HTML to the browser. Missing a better idea, I was wondering if there is something wrong with wrapping whole Smarty templates in {strip} tags like so? {strip} <div class="albums"> <h2>Alle Foto-Alben</h2> <ul ...

Smarty cached files invalidation

Hello, I'd like to go slightly deeper into Smarty caching, so I have some simple questions... To manipulate cache invalidation I want to know what directory Smarty is storing it's cache in. For example, all cached pages related to user_id=123 I want to store at cache/users/123/. Where cache is smarty caching dir. How can I tell smarty...

keeping smarty index on page reload.

hello everyone, I got a question. i have tha following foreach loop: {foreach from=$films item=film key=id} <tr> <td> {$film.filmtitel} </td> <td> {$film.zaaltitel} </td> <t...

Smarty sort array

Im looking to sort a list of product names being output by Smarty. Here is the current code: {foreach from=$products key=i item=product} <li> <a href="discuss.php?product={$product.uri} {if $filter_style}&amp;style={$filter_style}{/if}">{$product.name|capitalize} </a> </li> {/foreach} The HTML output: <li>zzzzz<...

Smarty Templates - Multiple Classes

Here is my template code: <li class="{$product.name}" {if $product.name == $filter_product.name}class=active{/if}"> I want to be able to set the $product.name as the class, and when the $product.name is the active filter also add the class "active" ...

Smarty - foreach loop 10 times and stop

Im using the following Smarty code: {foreach from=$entries key=i item=topic} {if $topic.topic_style == question} <li> <a href="topic.php?id={$topic.id}">{$topic.title}</a> </li> {/if} {/foreach} How can i do the {foreach} a maximum of 10 times and then stop? ...

SMARTY: ${ obj->render} doesn't render anything

Hi All I'm sending one of my object to smarty like $smarty->assign('test', new MyObject ) ; .... $smarty->display('main.tpl'); the MyObject class has a function called 'render' which returns a string representation of itself. So in main.tpl I want to render this object like {$test->render()} Unfortunately it doesn't show anythi...

Call PHP Function from Smarty with AJAX with no user action

I am hitting a lot of different sites to get a list of information and I want to display this information as I get it. Right now I am using a Smarty Template and what I would like to do is: Pseudo code: {foreach $page} $smarty_var = use AJAX to call a PHP function Render out a new table row on the fly w/ the newly assigned var ...

Need Help with this smarty

Hello, I am newbie & trying smarty for Gravatar plugin like this. <img src="{gravatar email="[email protected]"}"> But to get value of email I need to use {$client.email} So My final code look like <img src="{gravatar email="{$client.email}"}"> Which is not working. Where I am going wrong ? Thanks ...

smarty php variable not appearing

I am using the smarty templating system for php. I have the following within a .tpl file: <a href=\"{/literal}/view/{$tablename}/ where $tablename is a php variable defined in the php file that calls the .tpl $tablename = 'string'; However running the script only href="/view//" is visible. What am I doing wrong? ...

Smarty Nested foreach loop question

I am having trouble getting the below array to display properly in a smarty template file. If anyone can help point me in the right direction I would be most thankful. my template code looks like this: {foreach from=$trackingGroups item=gender key=k item=v} {assign var=tc value="`$v.id`"} {$v.title} (...