Making template with PHP ...

A

Anonymous

Guest
Hello all

I was wondering if anybody can help me (or give me some tutorial) about MAKING A TEMPLATE using PHP like the ones PHPBB done!

I mean its so strange when they have like:

Code:
<input type="submit" name="delete" class="liteoption" value="{L_DELETE}" />
 
<input type="submit" name="move" class="liteoption" value="{L_MOVE}" />
 
<input type="submit" name="lock" class="liteoption" value="{L_LOCK}" />
 
<input type="submit" name="unlock" class="liteoption" value="{L_UNLOCK}" />

How does {L_DELETE} work? I mean how simply can we make a template? Any good tutorial for that?
 
Code:
<html>
<head>
  <title>Page Title</title>
</head>
<body>
<h1>Header that goes on all pages</h1>
<ul>
  <li>Menu Item 1</li>
  <li>Menu Item 2</li>
</ul>
<?php
$Mode = $_GET['mode'];

switch($Mode)
{
    case 1:
        $File = "HomepageBodyText.html";
        break;
    case 2:
        $File = "AnotherPageBodyText.html";
        break;
    case 1:
        $File = "ADifferentPageBodyText.html";
        break;
}

$FID = fopen($File, 'r');

while(!feof($FID))
    echo fgets($FID);

fclose($FID);
?>
<h2>Generic Footer on all pages</h2>
</body>
</html>

Now, for the above example, lets say it was stored in a file called "index.php" . If you went to the url "www.wherever.com/index.php?mode=1" then the contents of "HomepageBodyText.html" would be pasted into the document.

Are you following?
 
Thank you, Yes I got it
but isnt that slow when you are using fgets while we have like hundred lines of code?

Is that the way professionals make template ?
cause I like to make my own but dont know how to start.

Ta
 
Most of the sites I've done recently pull the page data out of SQL, not other files.

If the files you are including are also php files and not html, you can use the include("filename") function to very quickly read them in. There's a bit of a slowdown since the target files will be parsed by PHP, but it may be faster for larger instances.
 
Thank you again for your answer
I think that is a very good way to do it.

Just one more question...
Do (TPL) files act like the one you told me as they seem to use some special variable like {L_MOVE} ?
 
Those parameters are telling a script how to act on a database to make changes to forum posts. That's all much beyond just conventional templating.
 
Back
Top