Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    problem in smarty .....

    Hello forum
    i am getting problem in smarty
    case:
    wwwroot/mySite/admin has files like
    -index.php
    -listA.php
    -listB.php
    /templates/ folder has
    -header.tpl
    -footer.tpl
    -index.tpl
    -listA.tpl
    -listB.tpl
    index.php contains
    PHP Code:
    <?php
    //in upper section it includes all the class files and creates the respective objects
    // neccessary processing goes here...
    $smarty->display("index.tpl");
    ?>
    index.tpl contains
    PHP Code:
    {php}
    if(isset(
    $_GET['action']))
    {
        
    $filename $_GET['action'].".php";
        if(
    file_exists($filename))
        {
            include 
    "$filename";
        }
        else
        {
    //error
            
    }
    {/
    php
    :::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

    problem:
    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!!

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks dude
    I got my problem solved
    one more question:
    how to perform the following with smarty ?
    -
    PHP Code:
    <?php
    $count 
    0;
    while()
    {
    echo 
    $count;
    $count ++;
    }
    ?>

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Smarty doesn't have a while function, but you should be able to use foreach or do the code in php and throw it back to Smarty.

  • #5
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    why would you want to do what you posted? I'm assuming there's meant to be a condition for the loop?
    Code:
    {section name=loop loop=10}
    {$smarty.section.loop.index}
    {/section}
    will output 0-9.
    Is that what you meant?
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •