PDA

View Full Version : Question about a php script to manage pages content


Proteus
12-22-2004, 03:50 AM
Let's say that I have my "header.php", "menu.php" and "footer.php" files. I call them together in another file called "template.php" using some basic php statements.

Now, I have the content pages called "page1.html" and another one called "page2.html".


My question is: how to do a single master php file where I call together:

"template.php" + "page1.html"

and

"template.php" + "page2.html"

and simply link my menu to a URL something like:

master.php?=page1

and

master.php?=page2

Any idea? any example?... :wink:

Thanks

robinev
12-22-2004, 06:49 AM
If I understand correctly what you're looking for, the problem sounds like something that could be solved using php includes.

I still use standard server-side includes, but I've looked a bit at php's include facilities. Their main advantage is that -- as I understand it -- that the server will interpret code not just in the main page, but also in any of the included pages. Another advantage is that you could use variables for the include instruction. Read the query string (the part after the question mark) and then build the page's main content area by calling different include files depending on the query string.

motorwatchercounter
12-22-2004, 09:34 AM
Hello Proteus,

As Robinev said, use the PHP include statement.

The 4 files (header, footer, main part1 and main part2) can be controlled by an external CSS page. The start code would be something like;

<html>
<head>
</head>
<body >
<? include("header.php");?>
<? include("main1.php");?>
<? include("footer.php");?>
</body>
</html>

on the right command main1.php calls main2.php so only the center of the page changes. Using the include means that you only need to have 1 generic header and footer and this does not need to be hard coded on each page. This makes it easier to control changes as one change effects the all the headers or footers.

Not spam I hope :wink:

Proteus
12-22-2004, 10:12 PM
Hello Proteus,

on the right command main1.php calls main2.php so only the center of the page changes.

Not spam I hope

What could be this command?...

I understand that I should use variables... but I still can't figure it out... Oh well, I need to study this more. I guess I have to keep using the include statement.

Thank you guys!

PS. Hey MWC, don't take the spam notice so seriously, I was joking around

motorwatchercounter
12-22-2004, 10:33 PM
No problems.

There is a free clasifieds script which uses the same technique (PHP & SQL). It is free so download it, pump it onto your server and you can mess about with it. It may give you some answers.

http://classifieds.phpoutsourcing.com/download.php

Proteus
12-28-2004, 12:48 AM
No problems.

There is a free clasifieds script which uses the same technique (PHP & SQL). It is free so download it, pump it onto your server and you can mess about with it. It may give you some answers.

http://classifieds.phpoutsourcing.com/download.php

That free software is a very good toy to play with... I feel like the time when I learned to fix myself my own stereo... :wink: Thanks for the tip!

Proteus
12-28-2004, 06:38 AM
By the way.. it comes with a shopping cart... I still can't figure out how this cart is related to the classifieds software or even how to implement it.... I guess is matter of time...