homepage Welcome to WebmasterWorld Guest from 54.237.95.6
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
"Post" Method
Need beginner help with the "post" method.
Echo_Tyme




msg:1276948
 3:32 am on Jul 11, 2004 (gmt 0)

Hello, i'm pretty new to php (I just use php require so far) and I've been hearing about the "post" method. Where you have one page with all the layout code, and the rest of the pages are just .txt files that you call up with what users click...

Basically when you change a layout, you change one page, and all your content is saved in their own files.

I've heard about it, but I don't know how to do it, if anyone can walk me through i'd be VERY greatful!

 

henry0




msg:1276949
 1:40 pm on Jul 11, 2004 (gmt 0)

Welcome on Webmaster World
I am not sure if I read you loud and clear
however it seems like you are going from
PHP basic to Object Oriented in one giant step
it this is your quest
you will need to first create a set of templates
that will hold the html/formating part of your pages
and that contain section where the content is called by using
<title><!--{PAGE_TITLE}--></title>
then you need per page (the page called in your prowser)
sometthing like
require_once ("include_fns_group.php"); // Include the DB configuration file.
require_once ("../classes/HtmlTemplate2_group.class"); // Include the class.

$page = new HtmlTemplate2_group ("../templates/main_template_chambdex.inc.php"); // Create an instance.

$page->SetParameter("PAGE_TITLE", "Member Home Page");

and of course the class section
that is above "required_once"
what the calss does:
// reads in a template, sets different values, and sends it to the browser

hope I am not off track
regards

jaski




msg:1276950
 1:40 pm on Jul 11, 2004 (gmt 0)

Welcome to webmasterworld Echo_Tyme.
"Post" method is a technical word which means some thing completely different from what you are talking about.

If you want to have consistent layout for all pages of your website then you need to be talking about "templates".

You can do that in a number of ways.
The easiest way probably is to write a simple php function to generate all pages.

eg. have one file "library.php"

--library.php--

// function to generate pages with a consistent layout.
function generate_page($body)
{
echo "
<html>
<head>
</head>
<body>
~~page header~~

$body

~~page footer~~
</body>

</html>
";

}

--end library.php--

--example.php--

include('library.php'); //included on top of all pages which need this layout.
$body = "<h1>Test Page</h1>";

generate_page($body);

--end example.php--

You can have any number of pages like example.php with different $body part and they will have consistent layout. To change layout you only need to change at one place that is generate_page function in library.php file.

Hope this helps.

Jaski

jatar_k




msg:1276951
 5:16 pm on Jul 11, 2004 (gmt 0)

Welcome to WebmasterWorld Echo_Tyme,

Maybe try this thread for a few different approaches to site templating
A dynamic site in 2 minutes [webmasterworld.com]

Echo_Tyme




msg:1276952
 10:08 pm on Jul 11, 2004 (gmt 0)

Hey thanks for the response, it helped alittle but like Henry0 said, i'm going from a basic php design into something I don't understand.

I tried reading your code but none of it really made sense >.< I just need to get this step out of the way, i've looked for it everywhere but no one seems to have any tutorials, maybe i should look for php templates. I mean I can get a very very basic grip on what your saying but I gotta know what goes where, like... explaining to a 5 year old.

I know no one is going to want to do that, but it'd be GREATLY appreicated.

On the Dynamic pages in 2 minutes (which i have right now) I understood this somewhat:

include $content;

in the middle. Then you just do this on every page.

$content = "pathtocontentpage.html";
include "template.php";

That makes alittle sense but I still don't know what's going on in the code, or what changes and what stays constant.

Jaski made alittle more sense with:

eg. have one file "library.php"

--library.php--

// function to generate pages with a consistent layout.
function generate_page($body)
{
echo "
<html>
<head>
</head>
<body>
~~page header~~

$body

~~page footer~~
</body>

</html>
";

}

--end library.php--

--example.php--

include('library.php'); //included on top of all pages which need this layout.
$body = "<h1>Test Page</h1>";

generate_page($body);

--end example.php--

But I still do'nt understand what's going on, what I change, what I keep, what the content is, what everything does. I can understand it I just never learned it, like I said I kinda need someone to explain it as if i'm a 5 yr old. And also like I said no one will really want to do this but I would REALLY appreciate it, and I can possible hook up a link or something from my site to yours, I just really need to learn this and understand it right now.

Thank you ^.^

Echo_Tyme




msg:1276953
 10:12 pm on Jul 11, 2004 (gmt 0)

I can't edit my post... well anyway I just re-read Jaski's method and it makes sense but I still have to know what's going on. He says to add all this stuff to pages that need it and everything, but i'm not seeing it.

I get it because it IS what I want, it's one page that has to be changed for layouts, while the content stays alone, so when I make a new layout, I change one page and all the rest is the same (content, etc). That's what i'm looking for, but I can't get a good grip on exactly what he's saying.

I think getting into more depth with Jaski's method can REALLY help, i'd greatly appreciate any help you can give ^.^

Thank You

Oh I found the edit button >.< lol.

Ok I gotta add this too... I need a template... we know that, but with that every page is alittle different... Every page has a different banner insde and a possible different footer. Right now it's setup dynamically, but to change layouts I need to change every page. Right now it looks alittle like this:

<html>
<head>
<title>Titletitle>
<META NAME="keywords" Meta tags>
<META NAME="description" Meta tags>
<link rel="stylesheet" href="/mmcss.css" type="text/css">
</head>
<BODY BGCOLOR="#FFFFFF" TEXT="#000066" LINK="#000066" VLINK="#000066" ALINK="#000066">
<SCRIPT language=JavaScript src="/menu/milonic_src.js" type=text/javascript></SCRIPT>

<scriptlanguage=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=/menu/mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=/menu/mmenudom.js><\/scr"+"ipt>");
</script>
<SCRIPT language=JavaScript src="/menu/menu_data.js" type=text/javascript></SCRIPT>

<br>
<br>

<?php require("http://mm.mysite.com/include/4_side.php");?>

<!-- 1st Main Table -->

<td valign=top width="450">
<DIV align=center>
<TABLE cellSpacing=1 cellPadding=3 width="100%" bgColor=#000033 border=0>
<TR>
<TD width="100%" bgColor=#000066><font color=#9FCDFF><center><b>Title</b></center></font></TD></TR>
<TR>
<TD width="100%" bgcolor=#F0F7FF>

Content

</td>
</tr>
</table>
</div>
<br>
<DIV align=center>
<TABLE cellSpacing=1 cellPadding=3 width="100%" bgColor=#000033 border=0>
<TR>
<TD width="100%" bgColor=#000066><font color=#9FCDFF><center><b>Title</b></center></font></TD></TR>
<TR>
<TD width="100%" bgcolor=#F0F7FF>

Content

</td>
</tr>
</table>
</div>
<br>
<DIV align=center>
<TABLE cellSpacing=1 cellPadding=3 width="100%" bgColor=#000033 border=0>
<TR>
<TD width="100%" bgColor=#000066><font color=#9FCDFF><center><b>Title</b></center></font></TD></TR>
<TR>
<TD width="100%" bgcolor=#F0F7FF>

Content

</td>
</tr>
</table>
</div>
</td>

<?php require("http://mm.mysite.com/include/4r_side.php");?>

</td>
</tr>
</table>
<tr>
<td>

<?php require("http://mm.mysite.com/include/bottom.php");?>

</td>
</tr>
</td>
</TR>
</TABLE>
</CENTER>
</DIV>
</BODY>
</HTML>

So I have alot of php requires which most can be in the template. But the footer changes on some pages and the .css file I have flucutates according to which page your on. Somehow I have to turn this into a template taht calls up the content... I dunno how in the world that'll happen, but you guys are experts not me lol.

Thank you for any help you can provide :)

[edited by: jatar_k at 11:38 pm (utc) on July 11, 2004]
[edit reason] generalized urls and trimmed code [/edit]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved