smarty

Smarty templates i18n.

Hello everyone. I just wonder about easy way to make i18n inside Smarty templates. Something like gettext() which i already use inside my PHP scripts. Any ideas? Cheers, Stanislav. ...

PHP based form validation

I'm looking for an easy to use, reasonably complete form validation solution for php. I recall using one years ago that used a few tags on the HMTL side then captured the OB to replace them with some pretty serious code. This feels slightly like overkill me, yet I'm not REALLY wanting to go nuts with my own right now. I'm using SMARTY...

Call to a member function on a non-object

I'm working through Practical Web 2.0 Appications currently and have hit a bit of a roadblock. I'm trying to get PHP, MySQL, Apache, Smarty and the Zend Framework all working correctly so I can begin to build the application. I have gotten the bootstrap file for Zend working, shown here: <?php require_once('Zend/Loader.php'); ...

Shouldn't mysql_real_escape_string() leave slashes in Database?

Hello Im using smarty and mysql_real_escape_string() for user input, and when I insert some code with ' or " , and lookup in phpmyadmin it shows without backslashes. When I get record from DB i doesn't have backslashes also. But when I just pass escaped string without inserting into the db it is backslashed. Shouldn't it add slashes, ...

Smarty replace text with double quotes

I have the following string in the smarty (php templating system) variable $test: <img height="113" width="150" alt="Sunset" src="/test.jpg"/> I want to add "em" to the height and width like this: {$test|replace:'" w':'em" w'|replace:'" a':'em" a'} But this doesn't work... What's the problem and the solution? ...

parsing html <script> via PHP isn't working completely.

I find this very strange, must be something I'm doing wrong, but still... I'm working on a page using PHP and TPL files. In my TPL file, there's a place in the footer for some extra lines if needed. For instance, formchecking with Javascript. so in PHP I did this: $foot = "<script type=\"text/javascript\">if(document.getElementById){l...

Smarty Plugin for Eclipse Europa

Are there any good Eclipse plugins for creating smarty templates? I am using Europa with PDT on Ubuntu (though I doubt the OS will make a difference for this). I found SmartyPDT, but it did not seem to install properly and some of the discussions on it seemed to suggest it was for an older version of PDT. ...

How do I check to see if a Smarty variable is already assigned?

How do I check to see if a particular value has already been assigned to Smarty and if not assign a (default) value? Answer: if ($this->cismarty->get_template_vars('test') === null) { $this->cismarty->assign('test', 'Default value'); } ...

Smarty benchmark, anyone?

Hey, I am considering Smarty as my web app templating solution, and I am now concerned with its performance against plain PHP. The Smarty site says it should be the same, however, I was not able to find anyone doing real benchmarking to prove the statement right or wrong. Did anyone do some benchmarking of Smarty vs plain PHP? Or may...

In smarty div position fixed is not working

In smarty div position fixed is not working. While this one is working in simple php. ...

Smarty Vs. Javascript/AJAX

I have a doubt: - Is there any standard/convention that when should I use "Smarty templating" and when should I use Javascript Ajax calls to produce the content? I can use Ajax/Javascript calls to produce the content dynamically. My application uses both Ajax and Smarty, but I want to set a rule for developers ...

Organizing files of a website powered by PHP, Smarty, JavaScript, MySQL

I am writing an web application powered by PHP, Smarty, JavaScript, CSS, MySQL. There will be some classes, which will be used through out the application. There will be some scripts which will use those classes. Any good article, tutorial, architecture on how to organize files for a web site? P.S. It should contain how to organize a...

Why should I use templating system in PHP?

Why should I use templating system in PHP? The reasoning behind my question is: PHP itself is feature rich templating system, why should I install another template engine? The only two pros I found so far are: A bit cleaner syntax (sometimes) Template engine is not usually powerful enough to implement business logic so it forces you ...

What is the best way to handle recursion in smarty?

I found a couple of ways to handle recursion in Smarty, mostly based on including templates into themselves, which seems like ridiculous waste of resources. I found one solution, by Messju over at Smarty that seemed to be just right - but it is not supported and fails in the latest version of smarty :( For people asking: What I want sma...

Regular Expression to match {if cond}foo{else}bar{/if}

Hi, I'm having difficulty throwing away the bits of the expression I don't want, and keeping the bits I do. The problem is - given the input string: {if cond}foo{else}bar{/if} I'd like just to have: 0: {if cond}foo{else}bar{/if} 1: cond 2: foo 3: bar And for the input string: {if cond}foo{/if} I'd like just to have: 0: {if co...

Smarter word wrap with Smarty?

I'm trying to find a way to wrap a long headline after a specific number of words, based on the total character count of the headline. My purpose is to make the bottom line of the wrapped text longer than the top line to increase readability. I'd like to use Smarty to find the character count of the headline, then decide how long to ma...

Smarty, the best choice?

We are developing a huge website, it will get lots of traffic, right now we are analyzing our options and Smarty looks nice but i have seen lots of flames about this, some love it some hate it. What do you think? Any real life experience with Smarty? If you hate it please write the reasons, same thing if you love it. ;) Advice about al...

Smarty: How to reference to the associative array index

Array $imagelist: Array ( [additional] => Array ( [count] => 2 [image] => Array ( [nokia_e61_1.jpg] => Array ( [name_body] => nokia_e61_1 [name_ext] => jpg ) [nokia_e61_2.jpg] => Array ( [name_body] => nokia_e61_2 [name_ext] => jpg ) [nokia_e61_3.jpg] =>...

Arrange elements into columns with Smarty

I have a php page that produces an array of elements. For the sake of simplicity let's say that it contains the numbers 1-5 in numerical order. These numbers need to be equally (or as close to equal as possible) split into two columns (using a html table) like so: 1 4 2 5 3 The number of columns might change in the future. Since t...

c file is not generated from tsmarty2c.php command

Hi, I am using smarty gettext plugin to internationalize smarty templates on windows. But when I run the command tsmarty2c.php c file is created but the strings are not in the file.C file is empty. I am using PHP 5.2.9 and smarty gettext plug in version is v 1.1.Any help is appreciated. ...