Jump to content


Photo

Insert template


  • Please log in to reply
13 replies to this topic

#1 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 08 August 2006 - 03:35 PM

Could someone walk me through how to bring a template into the php code being executed, I can't find how to do it.  Thanks in advance


#2 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 08 August 2006 - 04:00 PM

create your template in a file, say header.htm

then, in your php code where you want the template to appear, place the following line:

require('header.php');

#3 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 09 August 2006 - 09:43 AM

Thanks, another question, does this :
<?php
header("Location: $AUTHENTICATION_URL?url=$this->self_url")
?>
call the Authentication URL into the page that is open?

#4 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 09 August 2006 - 11:22 AM

I am not at all familiar with this construct.

#5 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 09 August 2006 - 11:29 AM

What I do is have my website in 3 parts shall we say

Header and nav

Body / Content

Footer

The header and nav does not include the doctype, html headers, but I suppose you can. My way

header/nav file contains the header and navigation of your website (page banner and side nav for example) all which shows in body tags

The footer shows the footer

then content is like

<html>
<head>
<title>MyTitle</title>
<meta....
</head>
<body>
<?php
require_once("inc_header.php");
?>
This is the body of that page

<?php
require_once("inc_footer.php");
?>
</body>
</html>

//Edit, only changed <? to <?php
Tell me the problem, I will try tell you the solution

#6 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 09 August 2006 - 01:00 PM

So do you open index.html in the browser or index.php?

#7 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 09 August 2006 - 01:45 PM

the pages would have to be php as you are using php code (unless you have your mimes set up)

but each page you make, use the same layout.

This means if you want to change the header, add a link in the nav, or change your footer, you edit one file, and all pages are updated, as all the pages are reading the information from that one file
Tell me the problem, I will try tell you the solution

#8 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 09 August 2006 - 03:20 PM

Is that the same as having seperate .html files and including <!-- Start and End Comment Blocks --> Where you want to insert your php code? I understand that.  What I don't quite get is how the .php file knows when to insert itself into the .html template.  Can anyone point me in the right direction.  Thanks

#9 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 09 August 2006 - 03:58 PM



When a .php file contains <?PHP ?> tags, it knows to execute the code within at the location where it is placed. 

#10 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 09 August 2006 - 04:10 PM

PHP Is a server side language
When you script contains <? or <?php (several other types but just use these 2) that data is passed to a PHP server, to read and translate back to HTM

Tell me the problem, I will try tell you the solution

#11 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 10 August 2006 - 09:11 AM

Yeah I understand this much, from what I have learned about templates so far, is to have seperate template.html files set up as such :
<html>
<head>
<title>MyTitle</title>
<meta....
</head>
<body>
<!-- START MainBody -->
This is the body of that page

<!-- END MainBody -->
</body>
</html>
Then to have your file.php to call the code within the template between the comment blocks, however I don't know how it does it?

This way I can say :
If userID = foo then display baa
else display foobaa

Any Pointers?

#12 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 11 August 2006 - 02:33 AM

it seems we're not speaking the same language?! ???

what exactly do you mean by template?  If you mean a page with basic structure that is shared among many pages, but with some places for page-specific data within, it'll be something like this

top of page shared by all pages

a bit of data unique to page

middle of page shared by all pages

more data unique to page

bottom of page shared by all pages


what you do actually, instead of creating one template page, is create separate template pages for the parts that are shared by all pages, e.g. top.htm, middle.htm, and bottom.htm. 

then each page in your site will be a .php page that looks something like this:
<?PHP
         include(top.htm);
         //code to generate output unique to this page
         include(middle.htm);
         //code to generate more output unique to this page
         include(bottom.htm);
?>


#13 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 11 August 2006 - 11:07 AM

This Guy here bfarber knows what I was trying to explain.

That way you would only need one file for the top, middle and bottom and call the parts at seperate intervals.

In theory one can also have a main bit of template also included that for intance has buttons to view reports, but with them labled like so in the html template:

<html>
<head>
<title>MyTitle</title>
<meta....
</head>
<body>
<!-- START Administrator -->
<a href='superReport.php'>superReport</a>
<!-- START Accounts -->
<a href='accountsReport.php'>accountsReport</a>
<!-- START Sales -->
<a href='salesReport.php'>salesReport</a>
<!-- END Sales -->
<!-- END Accounts -->
<!-- END Administrator -->
</body>
</html>

Now in your php file have this :

<?php

function whoReport()

if {

userType => 3 // 3 = Administrator
$this->ipsclass->template['_wrapper'] = str_replace( "<!-- START Administrator -->" , $this->ipsclass->compiled_templates['skin_global']->adminReport(), $this->ipsclass->template['_wrapper']);

} else if {

userType => 2 // 2 = Accounts
$this->ipsclass->template['_wrapper'] = str_replace( "<!-- START Accounts -->" , $this->ipsclass->compiled_templates['skin_global']->accountsReport(), $this->ipsclass->template['_wrapper']);

} else {

userType => 1 // 1 = Sales
$this->ipsclass->template['_wrapper'] = str_replace( "<!-- START Sales -->" , $this->ipsclass->compiled_templates['skin_global']->salesReport(), $this->ipsclass->template['_wrapper']);

}

?>

Along those lines, please note that code won't work.  But you can see what I am trying to do now I hope.  But if someone does know how to do this properly can they help me out, thanks.

#14 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 14 August 2006 - 03:16 PM

Also can you heve one template that is the main template that will always be there and have different templates fill the middle bit, or must you use frames?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users