Template problem

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
pedro84
Forum Newbie
Posts: 11
Joined: Sat Oct 21, 2006 11:28 am

Template problem

Post by pedro84 »

Hello Again:)


I have splitted my source for the files:
header.php
content.php
footer.php
menu.php

Source [part]:

Code: Select all

<div id="bckg"></div>

<div id="left">

<div id="menu">
<ul class="menu_t">
<li class="menu_item_lefth">&nbsp;Michael-Schenker.com</li>

My source is div based.


I have serious problems with my template. I don't know where I have to include files to make pages with different content. Do I have to put my tamplate in index.php? Or can it be juest like I've splitted it?
header.php
content.php
footer.php
menu.php?

I have read many tutorials but I haven't found what I'm looking for [Smiley U2]


Thanks in advance for help
Greetings
Pedro
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post by andym01480 »

Not a hugely clear question but here goes...

I am assuming you have a CSS file with the layout for your various divs?

If you have a different file for each of your content pages, you could do something like this....

index.php

Code: Select all

<?php
include("header.php");
include("menu.php");
//calling your content depending on the url variable pageid
if (isset($_GET['pageid'])){
switch ($_GET['pageid']) {
case 1:
    include("content1.php");
   break;
case 2:
   include("content2.php");
   break;
case 3:
include ("content3.php"); 
  break;      
default:
      include("content1.php"); // this stops pageid to be set by the user trying to break your script
}
}
else {
include ("content1.php");  //this one allows for just index.php to get default page
}

include("footer.php");
?>
Then you make...

content1.php with the content for page 1
content2.php with the content for page 2
etc

Your pages are called by the menu with urls like
index.php - which yanks up content1.php as the content
index.php?pageid=1 for content 1
index.php?pageid=2 for content 2
index.php?pageid=3 for content 3...

You could use this kind of layout to pull the page contents from a database!

Each of your include files contains the <div id=foo>Bar</div> etc

The header.php includes doctype, head, body tags
and the footer.php closes off the html
Hope that helps
pedro84
Forum Newbie
Posts: 11
Joined: Sat Oct 21, 2006 11:28 am

Post by pedro84 »

Oh my God!!

THANK YOU
pedro84
Forum Newbie
Posts: 11
Joined: Sat Oct 21, 2006 11:28 am

Post by pedro84 »

One more: how to put content files in subfolders? What will be path?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

yoursubdirectory/ :?
Post Reply