Page 1 of 1
Links. Hard question! :-D
Posted: Thu Feb 19, 2004 3:34 pm
by apollovega
Hello, I'll try to explain my situation as best as possible. What I'm trying to do is have one page as a basic blank page (let's say it's about.. Anime for instance). We'll call this page "Anime layout page". Now, there's no text when it's viewed in a web browser, so I make a series of pages that only have the text and information about the anime.
Now, I want to have one basic layout page (anime layout page), and a series of text pages, that can be changed by clicking a link although, keeping the same Basic Layout Page.
Think of it as frames in html. You really only have 1 page for links, and then another page (or a series of pages) inside the frame acting as the information about the website.
So basically, I want to click a link on my page and have the text information change, although keeping the main basic layout page the same all-around.
Is there any way to do this? Please reply if you don't get what I'm trying to ask (cuz I'm not that great at explaining things ).
Thanks in advance!
P.s = If it's possible to do it without using frames. Thanks again
Posted: Thu Feb 19, 2004 3:39 pm
by uberpolak
You want to get into templating, if I'm interpreting you right. What this means is that you build your layout page in HTML as you normally would, then, where you want it to display the text, you have something like this (not this exactly, there needs to be more, this is an example).
You need to have a script in your layout page before that to determine what $page will be. You can find some good information on how to do that at
http://www.project09.com/tutorials/PHP/templates-2/. This isn't the most secure method though, just a way to get started. Once you've handled this, search this forum for some stuff about security when templating.
Good luck.
EDIT: Sorry, meant
http://www.project09.com/tutorials/PHP/easy-templates/, the other one is a good follow-up though.
Posted: Thu Feb 19, 2004 3:45 pm
by apollovega
Yea, that's what I do with my website currently
But, I'd still have to input that piece of code on every basic layout page..
You see, when I make the blank page and I want to have links to different text area's, I have to make a basic layout page for every text page I have (in order to put the text information in with the "include("")" link.)
What I'm trying to do is have 1 layout page acting as the main page, and then whenever someone clicks a link the layout page doesn't change but the text page changes.
Is that a better explaination or?

Posted: Thu Feb 19, 2004 3:52 pm
by uberpolak
Then what you want is to approach it backwards. Make your links something like this:
Code: Select all
<a href="layoutpagename.php?p=textpagename">
Then, where you want to include the text on your layout page, put this:
Code: Select all
<?php
include($_GET['p'] . '.php');
//This will inlcude textpagename.php, so have that file contain your text.
?>
Make all your links like that, and it will just change the variable, then it reloads the layout page with different content.
Posted: Thu Feb 19, 2004 3:54 pm
by basdog22
say you have a link like:
Code: Select all
http://somehost.com/anime.html?item=manga
You make a <?php?> script like :
Code: Select all
<?php
if (isset($item))
{
include "$item.txt";
}
?>
You put this where you want the text to display and you are done
Note this will work with globals on.
For globals off you change the $item var with $_GET['item'];
templates
Posted: Thu Feb 19, 2004 3:56 pm
by josh
This is called templateing, I currently use this one of my websites, what you want is every page of information for example page1.htm first includes header.php ... then includes info_for_page_1.txt then includes header.php ..... every page is the same except it includes information2.txt etc.. or whatever you want...
for example:
Code: Select all
<!---
This file is the main page,
It fetches data from various different files when this page is requested
and "creates" this page dynamically, sends it to the browser, then this page is gone.
All of the content on this page are actually stored in data files.
--->
<!---get the header--->
<?php
$filename = 'head.txt';
$myvar = file_get_contents($filename);
echo $myvar;
?>
<!--end header fetch--->
<!-----begin title fetch---->
<h2 align="center"> <font color="#FFFFFF"><?php
$filename = 'main.txt';
$myvar = file_get_contents($filename);
echo $myvar;
?></font></h2>
<!---end--->
<!---get the header 2--->
<?php
$filename = 'head2.txt';
$myvar = file_get_contents($filename);
echo $myvar;
?>
<!--end header fetch--->
<!-----begin content fetch---->
<!--- </p> -->
<?php
$filename = 'who.txt';
$myvar = file_get_contents($filename);
echo $myvar;
?>
<!------end--->
<!-----begin footer fetch---->
<?php
$filename = 'foot.txt';
$myvar = file_get_contents($filename);
echo $myvar;
?>
<!------end--->
This opens some headers etc.. it also opens a file called head2.txt which i use to display the title of my page... useing this you could also write a simple php script to edit the text files... please make sure to chmod ur text files before posting problems.... for all those experienced php coders.. YES.. i realize that i could have used includes but its a long story its for a client and the way he wants to update his pages recquire either txt or sql and txt would be easier because it's a small site...
Is thsi what you were looking for.. this is the php code for
http://onlycheaters.com/tests
and you can update that ... if you knew my password

ill post the code for my admin section if you want or if you were looking for something different just tell me....
an easier way then to use php would be to just use iframe tags wouldnt it? but i suppose php is much "cooler" lol
Posted: Thu Feb 19, 2004 4:32 pm
by apollovega
Wow so many different ways! Thanks!
After looking over them (and trying some of them) I'm not quite sure if that's what I'm looking for... Here I'll give a url to pictures of what I'm trying to do.. It's the easiest way I can think of to explain it.. Like I said I'm not the best of explaining things. hehe
http://www.animewish.com/forum
Edit: Ignore the crude layout/text. It was meant to give you a general idea on what I'm trying to do.. Hard eh? :-/
Posted: Thu Feb 19, 2004 4:55 pm
by johnperkins21
Doesn't seem hard. You're still looking at using frames. Check here:
http://www.w3.org/TR/REC-html40/present ... def-IFRAME
Posted: Fri Feb 20, 2004 12:49 pm
by ol4pr0
i do not think ( almost sure ) that you can not create a full php code pages with frames.
you would always be looking at CSS / Java / Html ...ect
Posted: Fri Feb 20, 2004 3:17 pm
by apollovega
Thanks everyone. I finally got it to work (had to visit a number of forums that the question was asked and piece together the coding I wanted). Appreciate it!

Posted: Fri Feb 20, 2004 8:55 pm
by defx
Code: Select all
<?
if ($sect) {
include("$sect.txt");
}
else {
include("home.txt");
}
?>
this should work, just make your links go to ?sect=filename