SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

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

    Ive just started using smarty. I have a question about it.

    Im currently using a header template to put the header content in each page. So if i have a script called registration.php and an associated template called registration.tpl.html i include the header as usual:

    PHP Code:
    {include file="header.tpl.html"
    Now i have logic in this header.tpl.html which is assigned in a file called header.php. Problem is if access registration.php the header get loaded but its logic is not parsed.

    How do i include files such as header.tpl.hml and also make the logic within them get output?

  2. #2
    SitePoint Wizard triexa's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    2,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am no Smarty expert but it looks like the {include_php} tag may work for you, or change your logic to be within the header template or already "solved" before displaying registration.tpl.html...
    AskItOnline.com - Need answers? Ask it online.
    Create powerful online surveys with ease in minutes!
    Sign up for your FREE account today!
    Follow us on Twitter

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Location
    edge of nowhere
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to also include header.php into registration.php for the template to work properly.

    Recode your header.php in such a way that you can include it everywhere you are outputing your header and you should be fine.
    Programming boils down to three things: fast, good and cheap.
    Please pick two.

  4. #4
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I try to stay away from too much logic in the templates in Smarty, not that it's a bad thing, but our designer for instance, is no programmer (an excellent designer, but very graphics oriented). Too many loops extensions and if statements might make her head explode. Having said that, if you don't mind using them, smarty has ways of adding just about any logic you need, within the template. Just go through the documentation. It's not bad.

  5. #5
    SitePoint Wizard triexa's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    2,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Hammer65 View Post
    I try to stay away from too much logic in the templates in Smarty, not that it's a bad thing, but our designer for instance, is no programmer (an excellent designer, but very graphics oriented). Too many loops extensions and if statements might make her head explode. Having said that, if you don't mind using them, smarty has ways of adding just about any logic you need, within the template. Just go through the documentation. It's not bad.
    I can't think of ANYTHING you can't do in a template... just might have to use a custom function or modifier
    AskItOnline.com - Need answers? Ask it online.
    Create powerful online surveys with ease in minutes!
    Sign up for your FREE account today!
    Follow us on Twitter

  6. #6
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i still cannot get this to work....i have a template called cateogry.tpl.html and an associated code called category.php. If i include category.php in my results.php script and put an {include file="cateogry.tpl.html"} in results.tpl.html all i get is the cateogory output after the results tamplate has finished being parsed. I want the categories to appear in a div in the left ( where im putting the include file code in results.tpl.html) but it doesnt work.

    Im at a loss. If you cant include logic and templates and embed them in other templates and have them work as if they were running outside of another template then smarty is not all its cut out to be


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
  •