PHP & TPL files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maximus

    PHP & TPL files

    a simple questions.

    how can I echo a variable made on in a PHP file inside a tpl file.
    the TPL file is included inside the PHP file.

    any suggestions?

  • Juliette

    #2
    Re: PHP & TPL files

    Maximus wrote:[color=blue]
    > a simple questions.
    >
    > how can I echo a variable made on in a PHP file inside a tpl file.
    > the TPL file is included inside the PHP file.
    >
    > any suggestions?
    >[/color]

    Are you using a template parser ?
    If so, look in the documentation of the parser.

    If not, include the template only after you have created your variables
    and by having {$variablename} in the tpl file where you want the
    variable to be placed it will automatically be replaced.

    Even so, it all really depends on your set up, i.e. how the tpl file is
    used and interpreted, so the suggested solution may not work.
    If it doesn't give us some code so we can make educated suggestions.

    Comment

    • Maximus

      #3
      Re: PHP & TPL files

      Thanks Juliette. It worked.

      If there's any link can give me that provides info about TPL files i'd
      be thankful.

      Comment

      • Juliette

        #4
        Re: PHP & TPL files

        Maximus wrote:[color=blue]
        > Thanks Juliette. It worked.
        >
        > If there's any link can give me that provides info about TPL files i'd
        > be thankful.
        >[/color]

        Hi Maximus,

        If my suggestion worked, you don't need to read up on template files,
        you need to read up on the include statement and understand how that
        works: http://www.php.net/manual/nl/function.include.php

        If you really want to works with proper templating, you may want to look
        at some open source template parsers.
        There are numerous ones available, I won't recommend any as which one
        would be best, depends on your requirements.

        Grz, J.

        Comment

        • Tezza

          #5
          Re: PHP & TPL files

          I really recomend the PHP templating parser. I've heard it is really
          powerful. And from what I can tell in my experience, it is really easy
          to use.

          Comment

          • Ramon

            #6
            Re: PHP & TPL files

            What is a template parser? I use Savant currently.

            Tezza wrote:[color=blue]
            > I really recomend the PHP templating parser. I've heard it is really
            > powerful. And from what I can tell in my experience, it is really easy
            > to use.
            >[/color]

            Comment

            • Tezza

              #7
              Re: PHP & TPL files

              In this context, I suppose you could describe a template parser as a
              program which "processes" or "interperte s" template files.

              An example of a template is

              <?php include "BusinessLogic. php"; ?>
              <html><head><ti tle><?php echo $title ?></title></head>
              <body>
              <h1><?php echo $title ?></h1>
              <?php echo $content ?>
              </body>
              </html>

              and php is the program that can interperate this template. Note, your
              graphic designer can also load this template up in a product like
              dreamweaver and work with the design.

              Neat huh?

              Comment

              • Tezza

                #8
                Re: PHP &amp; TPL files

                I had a quick look at servant.

                It actually does use PHP for it's templates - which is good.
                I would say it is more of an application framework for controlling
                separation of concerns (SOC) and things like error management etc. So I
                quite like it. It's better than nothing, and will save you making your
                own application framework.

                However, I wouldn't use it myself.

                Comment

                Working...