Jump to content

Insert template


scottybwoy

Recommended Posts

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
Link to comment
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
Link to comment
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
Link to comment
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?
Link to comment
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]
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.