Jump to content

Archived

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

wuzzle

Layout template help

Recommended Posts

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");

?>

Share this post


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

Share this post


Link to post
Share on other sites
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:
[code]<?php
include("include.inc.php");[/code]
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.)

Share this post


Link to post
Share on other sites
Normally, what's in an included file [b]doesn't get changed[/b] significantly.  A normal arrangement might be:

[code]<?php
include("top_of_page_stuff.php");
?>

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

<?php
include("bottom_of_page_stuff.php");
?>[/code]

top of page stuff and bottom of page stuff act like 'wrappers' to the content.

Share this post


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

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.