Including a .php Into an already Templated Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Including a .php Into an already Templated Page

Post by NewfieBilko »

Say I got index.php, in which calls for the template index.tpl. And in that index.tpl is all your headers, and footers and such, html code. Say I wanted to have that template have a page include into the top of it. I tried <? PHP include('anewfile.tpl') ?> i've tried just using { } , i've tried linking a .php. Nothing seems to work... here is the code:

Code: Select all

<?php
  <td width="100%" valign="top" align="left">
    <table border="0">
    <!-- title -->
    <tr>
       <td height="21"><div class="titlePage">Client Information System</div></td>
    </tr>	
	<tr><td><?PHP include 'thebar.php'; ?><A href="/index.php" class="link">Home </A> ->  {if $p_admin eq 'y'}<a href="frmAdmin.php" class="link">Admin </a> -> <a href="/frmUsersGrid.php" class="link">Users</a>{/if}</td></tr>
    </table>

  </td>
  <!-- Login box -->


?>
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Many templating systems don't allow you to directly place PHP code into the template file. As templating system invariably have different feature sets and implementations, you should consult the documentation specific to you template engine to see if A) That particular feature is available and B) If so how.

In many cases you will have to grab the contents of the file and assign it to a variable then pass the variable to your template for inclusion.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

right, this system hasn't let me include any php code, besides code like:

{if permission eq y}show this html code{/if}

it will allow simple things like that. And some loops...

but i dont think it willl allow advanced functions like includes.. i guess.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

see im still just divulging around how im gonna get my dynamic links at the top to pull in what page its on.... note, my other post...
Post Reply