SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: smarty question

  1. #1
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    smarty question

    Hi,

    Im not new to templating...iver used pear html_template_it at work for some time...its very good but i thought id give smarty a go.

    Its very similar....setting variables, creating loops....although i have to say its a little more verbose than html_template_it but thats ok..

    One thing i cant find, that the pear package does, is a facility to ouptput a block of html...in html_template_it there is a facility to touch a block....say for instance the user has successfully updated some details then you can just say touch this block of html....in the html you just surround the block of html like so:

    Code HTML4Strict:
    <!-- BEGIN success_block -->
    //lots of html here
    <! -- END success_block -->

    Now can you do this with smarty...i cant spot it in the documentation...??

    Thanks

  2. #2
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Netherlands
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    {if $succes}
    Html goes here
    {/if}
    Go visit my site :-D you know you want to ;-)
    www.mech7.net

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thats great....i like how that works.

    Just one more question...ive just been messing about with smarty and results from a database query...i tried this:

    PHP Code:
    $sql "select last_name from users";
    $query mysql_query($sql);
    while(
    $row mysql_fetch_assoc($query)) {
    $smarty->assign("lastname"html_entities($row['last_name'])); 
    and then output it in the template like so:

    PHP Code:
    {section name=row loop=$lastname}
    {
    $lastname[row]} {/section
    but it doesnt seem to work....wheres the error? I mean i dont get an error it just doesnt output any last names....the php is fine if its run in a normal environment without smarty
    Last edited by elduderino; Aug 26, 2007 at 04:26.


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
  •