Pass PHP value back into TPL file

Discussion in 'PHP' started by fatinfo guy, Aug 22, 2006.

  1. #1
    I have this variable $pagecontents in a PHP file.

    echo <<<EOF
    $pagecontents
    EOF;
    PHP:
    How can I call up its value in a TPL file? When I use {$pagecontent} in the TPL file, nothing shows. Is there some syntax that's missing?

    edit: Problem solved, needed to assign the variable.

    $gDirSmarty->assign('auto_keywords', $pagecontents);
     
    fatinfo guy, Aug 22, 2006 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    Yes, you can also use
    $gDirSmarty->assign_by_ref('auto_keywords', $pagecontents);
    It can be better for performance and resources usage if variable value is large and you do not modify this variable anymore. Assign_by_ref makes reference to this var instead of making copy.
     
    wmtips, Aug 23, 2006 IP