The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Off-Topic (https://www.pokecommunity.com/forumdisplay.php?f=23)
-   -   PHP...how does it work for websites? (https://www.pokecommunity.com/showthread.php?t=9208)

Purin May 22nd, 2004 6:15 AM

PHP...how does it work for websites?
 
I've tried finding guides for this on the internet and books in the library, but the way they teach it isn't beginner-friendly IMO.
I'm thinking of changing one of my website's layout to include this, since frames don't look good on the current layout.

Rukario May 22nd, 2004 7:01 AM

All depends on what you want to do..

basic includes abd be done a couple of ways.. including header / footer info onto your content pages i.e. links to: page1.php, page2.php, etc.. or you can include content into a index (layout) page i.e. links look like: index.php?page=page1, index.php?id=dir/page, etc...

Then you can do active page generation using templates and other files (like how PC does it) It's all HOW you want to do it.
Basic content include code:
PHP Code:

// Nav and static content: 
<?php include ('path/to/file.ext'); ?>

// Content Pages code: 
// (this will include pagename.html into your index or layout page)
<?php
if (!$id) {
$id "main";
$include $id ".html";
}
else {
$include $id ".html";
}
if (
is_file($include) == "1") {
        include 
$include;
}
else {
include 
"404.html";
}
?>

All you do is create your layout / index.php, and where your content goes, you place the content page code. your main or home page should be named main.html The 404.html page is a generic '404 - can not find the page' error page incase of link errors and can also be set (using .htaccess) as your overall 404 page. If you want your nav links to be included then you reomve then from index page, then save them as nav.inc (or .txt, or .html, etc.. ) and use the static include code. You can see it's a lot like ssi and is so much cleaner then frames.

aRedMoon May 22nd, 2004 7:02 AM

Well, there are a couple ways... I'll show you two of 'em. And I'm assuming your friend is using a typical 3 column site with tables.


Code:

You can do it in a way where there are two different layout pages.  In "layout1.php" you would write something like...

<html>
<head>
<title>Blue Bar</title>
</head>
<body>
<table width="100%">
<tr><td width="100%" colspan="3"><center>BANNER</center></td></tr> <!-- That's the banner -->
<tr>
<td width="15%">Everything in the first column would go here.</td>
<td width="70%">

And that's layout1.php.  Then you make layout2.php

</td>
<td width="15%">You'd put the right column stuff in here.</td>
</tr>
<tr><td colspan="3">Put a footer here</td></tr>
</table>
</body>
</html>

Save it.

Now, for each page of content, the page should look similar to this
<html>
<head>
<title>Blue Bar</title>
</head>
<body>
<? include("layout1.php") ?>
Everything in the main section of the page goes here.  Content, everything.
<? include("layout2.php") ?>
</body>
</html>

And there you have it, a page where the layout can be editted simply by changing 1 (or 2) pages, and not every single page.  And it doesn't look funny, like the frames.  :P



Code:

Now, there is another way I know of.  Though, it's a tad more tricky... you just have one layout file...
<html>
<head>
<title>Blue Bar</title>
</head>
<body>
<table width="100%">
<tr><td colspan="3"><center>BANNER</center></td></tr>
<tr>
<td width="15%">Left column stuff.</td>
<td width="70%"><? print("$content") ?></td>
<td width="15%">Right column stuff.</td>
</tr>
<tr><Td>Footer</td></tr>
</table>

Save that as layout.php...

Then for each content page, you have to do it like this...

<html>
<title>Blue Bar</title>
<body>
<?
$content = "Whatever you want in the content.  You can not use double quotes in here.  For changing fonts, etc, you have to use single quotes like... <font color='blue'>Blue font</font>" ;
//Make sure you add that ending quote and the ";"!!!

include("layout1.php");
?>
</body>
</html>

Then save that as whatever.  That was, when you go to yousite.com/content.php, it will read what the variable is (you defined the $content variable by doing the $content = "X") and then print it after it loads the layout.  It doesn't work if you include the layout first, as it prints it without knowing what $content is, so it leaves a blank space.



And that's all I have to say... hope that was some help!

Purin May 22nd, 2004 7:25 AM

It's still very confusing for me, since I'm self-taught in a lot of things when it comes to computers and websites.
Sorry for the trouble btw.

aRedMoon May 22nd, 2004 7:35 AM

PHP, although the say it's a simple language to learn, does confuse a lot of people at first.

So don't feel bad. :P

Purin May 22nd, 2004 7:40 AM

Quote:

Originally Posted by JKaizer
PHP, although the say it's a simple language to learn, does confuse a lot of people at first.

So don't feel bad. :P

The guides from you and PPNSteve look useful (they might be), so I'll save them down to read and compare with this library book that I borrow (which isn't of much use, from what I think).
Once I've learned it, I might try my hands on making a guide that will be simple to understand for beginners with at least some HTML knowledge.

Rukario May 22nd, 2004 7:46 AM

what we've shown you is very basic and basiclly replaces SSI and/or frames..
it's easy to convert existing pages (framed or ssi) using these codes.. (great if you have lots of existing pages)

But php is far more usable in generating active pages, preforming funtions, etc... and you really should read a few books and maybe do a search for tutorials on the web, just to help you understand those overly complex books.

pokemon706 May 22nd, 2004 7:46 AM

i can host ya, and then help ya lol

Purin May 22nd, 2004 7:51 AM

pokemon706: I've already got a host for that website. Thanks for the offer anyway.
What's the difference between SSI and PHP?

Imakuni? May 22nd, 2004 8:16 AM

http://www.kyletech.us/pokemon-tns/php.php theres a guide i helped write for php includes

aRedMoon May 22nd, 2004 10:17 AM

SSI is an older way of doing the functions that php does. At least that's what I think...

Kipkip May 22nd, 2004 11:06 AM

Quote:

Originally Posted by Purin
pokemon706: I've already got a host for that website. Thanks for the offer anyway.
What's the difference between SSI and PHP?

For SSI, what you will need is a right column layout page and a left column layout page. Then you put in include into where you want the right and columns on the content page. That's all I know about SSI.
If you want to extened you knowledge of PHP, I recomend http://www.w3schools.com.

Geometric-sama May 23rd, 2004 3:53 AM

Oh, I see, I've been wanting to know how to do that for ages! I'll do my Physics project using that XD

Simone May 23rd, 2004 3:57 AM

SSI is server side includes, its got the extension .shtml like Serebii.net or mewshangout.net.

Using PHP is a much more useful and easier way to make a website. Because alot of newspros, cutenews, fusion news use PHP, they need a php page to run properly.

Also, I cna probably host you if you ever need a server. But i don't do free hosting usally, i just see potencial in your site. (don't worry i have my own server ,its fast enough lol.)

mewthree w/armor May 23rd, 2004 4:12 AM

Quote:

Originally Posted by Simone
SSI is server side includes, its got the extension .shtml like Serebii.net or mewshangout.net.

Using PHP is a much more useful and easier way to make a website. Because alot of newspros, cutenews, fusion news use PHP, they need a php page to run properly.

Also, I cna probably host you if you ever need a server. But i don't do free hosting usally, i just see potencial in your site. (don't worry i have my own server ,its fast enough lol.)

Coranto at least does not need a php page to run, works just fine on my shtml page.

aRedMoon May 23rd, 2004 8:33 AM

WEll I guess some might work on an shtml page, but meh. Most won't.

Purin May 23rd, 2004 11:02 PM

Coranto does, but my news will be ruined on tables for no reason.
I don't know...


All times are GMT -8. The time now is 6:12 PM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.