Jump to content

Archived

This topic is now archived and is closed to further replies.

scottybwoy

Insert template

Recommended Posts

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

Share this post


Link to post
Share on other sites
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');

Share this post


Link to post
Share on other sites
Thanks, another question, does this :
[code]<?php
header("Location: $AUTHENTICATION_URL?url=$this->self_url")
?>[/code]
call the Authentication URL into the page that is open?

Share this post


Link to post
Share on other sites
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

[code]
<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>
[/code]

//Edit, only changed <? to <?php

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites


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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 :
[code]
<html>
<head>
<title>MyTitle</title>
<meta....
</head>
<body>
<!-- START MainBody -->
This is the body of that page

<!-- END MainBody -->
</body>
</html>
[/code]
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?

Share this post


Link to post
Share on other sites
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:
[code]
<?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);
?>
[/code]

Share this post


Link to post
Share on other sites
This Guy here [url=http://forums.invisionpower.com/lofiversion/index.php/t198295.html]bfarber[/url] 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:

[code]
<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>
[/code]

Now in your php file have this :

[code]
<?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']);

}

?>
[/code]

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

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.