Jump to content

Recommended Posts

Hi!

 

First of all, great site!

 

I was wondering, i've looked into some of the PHPBB files, and I notice that they use HTML template files.

How do they include their PHP variabels into those files? I can see they use something like {VARIABEL_NAME} inside their files, but i cant quite figure it out.

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/112811-making-templates-with-php/
Share on other sites

I usually take a pre made template from a free template website, or I will make my own, as if it was a html website, then I will put blocks of  html code in php include to I can call the template with one include file.

 

But the separation of HTML and PHP is usually much easier to work with, and it makes the output template independent of the PHP code.  If you need to change the way something looks with your method, it often takes a long time to rewrite it, but with templates, you just update the template and the PHP logic remains the same.

na I have a head and a foot, and I set some variables like

 

$login = "yes";

$path = "../../;

echo '<a href="'.$path.'index.php">Login</a>';

 

and the php file loads the login for that page, I have had no problem yet using my method, but it is what you like best

Or you could alternatively use PHP's built in templating engine.

 

<html>
  <head>
    <title><?=$website['title'];?></title>
  </head>
  <body>
    <? if($online) : ?>
      <!--Your regular page here.-->
    <? else : ?>
      <!--Website offline display message.-->
    <? endif; ?>
  </body>
</html>

 

Personally I don't mind using shorthand PHP tags when it's inside a HTML document. I don't ever declare a PHP document with them though. Also, it doesn't comply with PEAR coding standards (at least I don't think so).

Or you could alternatively use PHP's built in templating engine.

 

<html>
  <head>
    <title><?=$website['title'];?></title>
  </head>
  <body>
    <? if($online) : ?>
      <!--Your regular page here.-->
    <? else : ?>
      <!--Website offline display message.-->
    <? endif; ?>
  </body>
</html>

 

Personally I don't mind using shorthand PHP tags when it's inside a HTML document. I don't ever declare a PHP document with them though. Also, it doesn't comply with PEAR coding standards (at least I don't think so).

 

1) Short tags make me die a little on the inside when used at all. =(

2) Smarty does it so much cleaner than that though.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.