Jump to content


Photo

Layout template help


  • Please log in to reply
4 replies to this topic

#1 wuzzle

wuzzle
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 August 2006 - 09:57 PM

Alright here's my problem.  I currently have a layout php called include.inc.php which holds this code:

Echo "$SHTM<table border=1>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
$EHTML";

?>

Now my issue is when I want to include this layout into other pages whenever I add text to a new .php it puts it after the table, when I want it to go into either cell 1 or cell 2 of the table.  Now I'm pretty sure the below code is correct, however I do not know what to put after the include("include.inc.php"); part in order to edit the certain cells.  Any help would be amazing!

<?PHP
include("include.inc.php");

?>



#2 onlyican

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

Posted 02 August 2006 - 10:30 PM

an include (and require) add the script when it is called

my include file could say "This is an include"

If I have my page

"This is text<br />

<? include("myinclude.php"); ?>

<br />this is more text

The output would be

This is text
this is an include
this is more text
Tell me the problem, I will try tell you the solution

#3 wuzzle

wuzzle
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 August 2006 - 10:44 PM

Ok, but lets say my include file is my layout (so I can just change this one file to change every page) - I'm going to want to put it first in my php file, thus the:
<?php
include("include.inc.php");
at the very start of code.

What I need to know is how to insert text or other things in the middle of this include.inc.php file.
-------------
So an example (this is my include.php file)
<?php

Echo "$SHTM<table border=1>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
$EHTML";

?>


My index page needs a welcome message and my layout is just a normal two cell table.  I want to insert the word hello into the second cell by changing the /index.php file while leaving the include.inc.php file alone.  And then another page (lets say index2.php needs to say another message in the cell 2, but only by changing the index2.php.

index.php file:

<?PHP
include("include.inc.php");

?>


??? ??? ??? (PS sorry I'm very noob at PHP and I hope this makes sense.)

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 02 August 2006 - 10:50 PM

Normally, what's in an included file doesn't get changed significantly.  A normal arrangement might be:

<?php
include("top_of_page_stuff.php");
?>

<!-- your page content goes here-->

<?php
include("bottom_of_page_stuff.php");
?>

top of page stuff and bottom of page stuff act like 'wrappers' to the content.
Legend has it that reading the manual never killed anyone.
My site

#5 onlyican

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

Posted 02 August 2006 - 10:51 PM

You CAN
have on your include
<td>".$cell1."</td>
<td>".$cell2."</td>

Then on your page BEFORE the include
$cell1 = "This is the stuff that goes in cell 1";

$cell2 = "This is what shows in cell 2";

but Andy is sorta correct

The point of an include is you can change something, and every page changes
For example
All my websites
I have an include of navigation

so I want to add a link or something, I change one file
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users