SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question replacing array's value in Smarty

    Hello Everyone!

    I have a table in mysql database which is connected to another one through an id number. What I am trying to do is to replace that id number with "name" field which is in table two. I know I would need to execute two querys but I am not sure how could that be done. Should I execute the other query after the array has passed to smarty engine or before?

    Thanks for the help guys!

  2. #2
    SitePoint Zealot shaman's Avatar
    Join Date
    Feb 2005
    Location
    W.R. Home
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as I know, Smarty has method assert_by_ref(), if you pass your array to smary as reference, you can change it after passing.
    She's my german fraulein

  3. #3
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by shaman
    as I know, Smarty has method assert_by_ref(), if you pass your array to smary as reference, you can change it after passing.
    I have just check out Smarty's official manual but there is no such function assert_by_ref(). Are you referring to assign_by_ref()? If so, then could you please demonstarte an example on it?

    Thasnk you for the help!

  4. #4
    SitePoint Zealot shaman's Avatar
    Join Date
    Feb 2005
    Location
    W.R. Home
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops, yeap assign 8)

    what kind of example do you need?
    She's my german fraulein

  5. #5
    SitePoint Zealot shaman's Avatar
    Join Date
    Feb 2005
    Location
    W.R. Home
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe this?
    PHP Code:
    $vars = array( "name" => "Mary""family" => "Popins" );

    $tpl->assign_by_ref"user", &$vars );
    // now in your template, {$user.name} == "Mary" and {$user.faimly} == "Popins"

    // let's change variable
    $vars['name'] = "Sheril";
    $vars['family'] = "Bobins";
    // and now {$user.name} == "Sheril" and {$user.faimly} == "Bobins"

    $tpl->display"your.template.tpl" ); 
    She's my german fraulein


Bookmarks

Posting Permissions

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