View Full Version : problem in smarty .....

03-02-2007, 11:10 AM
Hello forum
i am getting problem in smarty
wwwroot/mySite/admin has files like


/templates/ folder has


index.php contains

//in upper section it includes all the class files and creates the respective objects
// neccessary processing goes here...

index.tpl contains

$filename = $_GET['action'].".php";
include "$filename";

:::means it automatically includes the file as per $_GET action
suppose i clicked on the link ?action=listA then it auto includes the page listA.php which then display the array data in listA.tpl

It was working in normal case ie without using smarty but Now whenever i clik on the links
it shows:

Call to a member function selectAll() on a non-object in C:\Program Files\xampp\htdocs\mySite\admin\listA.php on line 39

i am not getting the solution please help.
Thanks in advance to all of you!!

03-02-2007, 01:10 PM
Having php in your templates isn't generally a good idea, why are you doing that? The whole point of using a templating system is to help you separate your logic from the presentation, resorting to {php} tags is a sign that you're doing something wrong.

The error is referring to a line in listA.php, would it perhaps be useful to have pasted that to look at?

Including files directly from user input is a really, really bad idea.

03-02-2007, 03:33 PM
Thanks dude
I got my problem solved
one more question:
how to perform the following with smarty ?

$count = 0;
echo $count;
$count ++;

03-02-2007, 07:59 PM
Smarty doesn't have a while function, but you should be able to use foreach (http://smarty.php.net/manual/en/language.function.foreach.php) or do the code in php and throw it back to Smarty.

03-04-2007, 12:18 AM
why would you want to do what you posted? I'm assuming there's meant to be a condition for the loop?

{section name=loop loop=10}

will output 0-9.
Is that what you meant?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum