php with templates

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
saja123
Forum Newbie
Posts: 1
Joined: Tue Apr 22, 2003 9:14 am

php with templates

Post by saja123 »

hi guys

i came across with some probelms when i was doing the assignment.
okay here is the problem!
i have created templates. but i cant figureout whether we need templates to all the pages.
i have created a templates for leftnavigation and the header

the thing is u add these leftnavigation and header templates for each page. but how do u do the design of each page. say if u have a seperate page for search! do we put the design part of the search page in a templet and then call it as the content or do we just leave it as an html page. if u r unclear what i'm trying to say. please take a look at this:

structure that i am talking about:.
if i wanna do the search page
i have

1) leftnavigation.tpl
2)header.tpl
3)searchbody.tpl
4)search.php

searchbody.tpl contains the design part of the body.
and search.php will be looking like this:

<?php
include './template.inc';
$tpl = new Template('.');
$tpl->set_file(array('std' => 'std.tpl',
'header' =>'header.tpl',
'leftnav' =>'leftNavigation.tpl',
'content' =>'searchbody.tpl'));
//$tpl->set_var('title', 'Lets watch Plays');
$tpl->parse('header', 'header');
$tpl->parse('leftnav', 'leftnav');
$tpl->parse('content', 'content');
$tpl->parse('DUMMY', 'std');
$tpl->p('DUMMY');
?>

in hear i have called searchbody.tpl as the content part. what my problem is whether u do it like that or just do the searchbody design in an html page.

is this right? i'm bit confused coz when u r doing the validation using java script (client side scripting) then i will have to do them in the searchbody.tpl file.
if so do we have to do like this for each page.
To tell u the truth i have already design all the pages like this. now i'm bit afraid it's not the way u do it!

please reply me if u can. will be a great help

thanks
saj

:cry:
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I always use html templates to format browser output - just include them wherever they're needed.

I would guess that's more efficient than parsing a php template class to write the same html.

And I usually have javascript turned off when I'm browsing :wink:
Post Reply