smarty

Stripping whitespace out of smarty templates from PHP

Is there a way to tell Smarty from PHP that you want it to strip all the whitespace in your templates before sending to browser, as if all your templates were embedded in {strip} tags? Some sort of Smarty object parameter or something? ...

Smarty: Restart {cycle} using nested {sections}

I am trying to generate background colors for multiple tables that are contained withing a {section} ... {/section} block, but if I don't give names to the {cycle} functions, the cycle is continued, not restarted the next time it is encountered. The same problem occurs when I use named cycles and the same named cycle repeats in a section...

Passing smarty Variables in a include ( with Codeigniter )

Hello, I'm very newbie to php and codeigniter (and smarty too). I follow a lot of tutorials and Now I'm confident with my smarty + CodeIgniter configuration, but now I have this escenario. I want to pass a couple of variables into a smarty include in order to show just two strings in the include ( the header, the strings are part of the...

Please help with smarty template error

I just moved my website to another server and i got this error message using smarty template http://bit.ly/5MZu2A Here is part of the smarty file: /** * DIR_SEP isn't used anymore, but third party apps might */ if(!defined('DIR_SEP')) { define('DIR_SEP', DIRECTORY_SEPARATOR); } /** * set SMARTY_DIR to absolute path to Smarty l...

Smarty jQuery/Ajax call barrier

I'm modifying an existing system which uses Smarty. This particular problem is causing a major stumbling block as I just can't find a way around it. I have a data-grid, each record has an action which calls ?module=the_module&action=the_action. My corresponding function function the_module_the_action($postData, $getData) is used to per...

smarty template compile directory not writable

hello all, i'm using the latest version of smarty (3.0rc3). i made my templates_c directory writable in command line (chmod -R 777 templates_c) but smarty still outputs this when i call $smart->utility->testInstall(); Testing compile directory... FAILED: ./php/classes/smarty/templates_c/ is not writable. Warning: rename(/tmp/wrtub1GxS,...

3 Column Layout - Looping through Dynamic Data

Hello all, I have list of categories that is contained in li's on one column of my page (side bar). I now want it to span the whole width of the page in several columns. I would always like 3 or 4 columns to fit the page. This is the code that generates the one column. <div id="sidebar"> <ul> {insert...

Using Smarty, is it possible to call a method on the return value of a method?

I have the Smarty code {$obj->foo()->bar()} and Smarty complains about 'unrecognized tag' in the expression. If I change it to just {$obj->foo()} it doesn't complain, so I assume the problem is with the fact that I'm calling a method on the result of a method. Is this a limitation of Smarty's parser, or am I missing something else ...

Php _REQUEST variable problem (using smarty template)

My understanding is that _REQUEST consists of the GET, POST and cookie data. I have a _REQUEST variable that is filled up with data using GET ie from the URL. This is where I have a couple of problems. I thought that GET data was communicated in the url like: www.example.com/empty?g=o&h=s so with that url the REQUEST would have _$...

How to use frames in smarty

Here is the php file <?php require_once ('lib/config.inc.php'); require_once ('lib/smarty.php'); require_once ('lib/DataBase.php'); $n="shaz"; $p="pwd"; //Data Retrieving $db = new DataBaseReader(DB_HOST, DB_NAME, DB_USER, DB_PASS); try{ $db->connect(); $user = $db->login($n,$p); if($user=="false") echo "no login" ; ...

javascript file doesnot load in smarty

{literal} <SCRIPT LANGUAGE="JavaScript" SRC="../calendar/weeklycalendar.js"> </script> <script> // call the function to build the calendar // function's param specify the first day of week // 0=Sunday, 1 = Monday, ..., 6=Saturday alert("before"); buildWeeklyCalendar(1); alert("afetr"); </scrip...

What is wrong with this Smarty php templating code?

What is wrong with this Smarty php templating code? If I include either of these two loops individually in the file, they work. But if I have them both in the file like below only the first loop gets completed. {include file="vote_js.tpl"} {section name=i loop=$posts} {include file="posts_bitother.tpl"} {/section} {...

Gettext (i18n) and Smarty running erraticly

I'm developing a webapp with PHP and Smarty. I use gettext to internationalize, but I've a problem: it only works sometimes, absolutly randomly. I load a locale ('de_DE', by example) with putenv+setlocale+bindtextdomain+textdomain, reload the page, and see "Search"; reload again and I see "Suche"; two more reloads and get "Suche" but thi...

Smarty custom plugin to use base class

Here is my class that gets called on each page: class ActionHandler { var $smarty = NULL; public function __construct() { if($this->smarty == NULL){ $this->smarty = new Smarty(); $this->smarty->template_dir = TEMPLATE_DIR; $this->smarty->compile_dir = COMPILE_DIR; } ...

Why templating engine: smarty or phptemplate, any other?

I'm trying to compare between the different template engines for PHP. The 2 that come up are smarty and PHPtemplate. How do I decide which is better for me.. These are some of the questions I'm trying to find answers to What are some of the strengths and weaknesses of these 2 Is one better than the other in some cases or for some typ...

Invalidating cached category pages (page1, page2 etc.) when new post is added?

Hello, Let's imagine that we have blog with category A. Category A is currently having 1000 posts on 100 pages. All pages are cached in files (for example, cached by Smarty template engine). I'm adding post and want it to be displayed on first page immediately. So, I have to clear or invalidate cache for all 100 pages of category A. De...

php range query

Hi, Basic question here. I am using php(smarty) range to populate an array for days in the month. $smarty->assign('date', range(1,31 )); The form sends OK, but because counts start at 0, when I pick 20 from dropdown 19 gets sent in the form. How do I set it so it starts at 1? ...

How to use objects in templates in secure way

Hello everyone Modern template engines for php (say, dwoo or smarty) can use objects as variables. You can use {$obj->method()}, which is really convenient, and i am using this a lot. But, there is a clear security problem with exporting directly objects from ORM, which have methods such as insert, delete etc. Is there any sane method ...

Posting an array in php(smarty)

Hey, I'm trying to post multiple answers(using checkboxes) in a form. The question is pick what months your available, here is my code... $smarty->assign('month', array( '1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10'...

Dynamic Google Direction problem

In my site I am trying to generate dynamic google map direction. The destination is dynamic. All I am doing is: Here, {$map_code} is generated by me. This works fine. I am trying this above code to be appeared by jquery ajax within a div. where the locations are generated and also the script code. but problem is that, when ajax is wri...