| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read | ![]() |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi
i want to make a a page (php) and in the menu to have links that call external files (either html, or php, or txt) which contain the main content. That content would like to be placed each time in the first page which is like a template. so a typical address would be server.com/index.php?p=music This is easily done but the thing that i can't do is when you click the links i don't want to have the complete page -template- loaded, i prefer to have only the text changed in the main area and everything else like top area with logo, banner and bottom area with emails numbers etc to stay as is. is that something possible with php? do i have to use frames? hope not. please be easy on me, its my first post! ![]() |
|
|||
|
(Right, the contest starts exackly now and I think I'm the first person to help =D 12:00:00 21st of January and I damn hope the below post counts
The only way I could think of this is to create a new page; e.g. index2.php Use Code:
<?
$site = $_GET['site'] . ".php";
if(file_exists($site)) {
include($site);
} else {
include('page.php');
}
if(($_GET['site']))
?></td>
If I had to do that, I would do it that way. Good luck |
|
|||
|
I should have been clearer.
I have a template page index.php. I also have text files (music.txt, events.txt, links.txt etc) that contain all the content - text. In my index.php page I have the menu section. Each link calls each text file and the contents of the text file appear in the index.php. the links look like this: <?php echo htmlentities($_SERVER['PHP_SELF']);?>?p=events">Events</a> when i click the links work fine but the template page is loading every time and i'd like not to. i just want the main area, where the contents of the text files appear, to reload and not the whole index.php is that more understandable? i hope thanx |
|
|||
|
Hi pepperoni,
I can offer this as a solution. It may not be suitable as it loads the whole page including all your 'bits'. However, by clicking the links only the selected section is displayed. It uses javascript (which I don't like) but is fairly simple to understand. <HTML> <HEAD> <style type="text/css"> .head { font-family: Arial; position: absolute; top: 1; visibility: visible; z-index: 2; } .text { font-family: Arial; position: absolute; top: 170; visibility: hidden; z-index: 2; } </style> <SCRIPT TYPE="text/javascript"> var pageLast = 0; function fwd(pageNext) { document.getElementById(pageLast).style.visibility = "hidden"; document.getElementById(pageNext).style.visibility = "visible"; pageLast = pageNext; } </SCRIPT> </head> <body OnLoad="fwd(0)"> <DIV ID="head" CLASS="head"> <h1 align="center">Some Heading here</h1> <h2 align="center">A bit more here</h2> <p align="center"><b>Blah, blah, blah.</b></p> </DIV> <DIV ID="0" CLASS="text"> <P>NOTE: This is the first section of text. This is displayed when the page is first loaded. To get to the next section <U OnClick="fwd(1)">click here</U></P> </DIV> <DIV ID="1" CLASS="text"> <P>This is the second section. You can have mulitple choices like this. Where do you want to go now? -<BR><BR> part 2) <U OnClick="fwd(2)">Section 2</U><BR> section 3) <U OnClick="fwd(3)">Section 3</U><BR> page 4) <U OnClick="fwd(4)">Section 4</U></P> </DIV> <DIV ID="2" CLASS="text"> <P>Etc, etc, etc. Where now?<BR><BR> a) <U OnClick="fwd(0)"> Back to the start?</U><BR> b) <U OnClick="fwd(1)">You should be able to work out the rest</U></P> </DIV> </BODY> </HTML> |
|
|||
|
Hi
Check out some AJAX howto's - this is where you can build one template page and load other pages into DIVs dynamically. The two languages that can do this are PHP and ASP. I use ASP, so can help on the mechanics, just not the PHP syntax. I won't bother writing a HOWTO here as there are plenty already out there. Go check AJAX PHP on Google... Chris |
|
|||
|
if you don't want to use frames then you need to create a rich internet application environment using something like Ajax, Flex,Openlaszlo, zend studio,etc.
Most popular language for this sort of project is javascript, and populating div tags dynamically 'on the fly' Zend studio uses php and javascript as its main languages. Ajax with the Spry framework also can create what you need, and I would suggest probably the easiest of all to learn as the javascript is already written for you.
__________________
West Dorset Community |
|
|||
|
just to let you know i found those two pages and everything works great.
its exactly what i was thinking to do. quite happy!! ![]() hxxp://homepage.mac.com/kevinmarks/staticjah.html hxxp://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm thought i have doubts if that's the best solution... cause it wont work if people disable javascript. maybe there is something around with html+css which work in every browser. i'll keep ajax for now. cheers |
|
|||
|
It used to be a couple years ago that some people did disable jscript as a matter of course, but that is not true in this day and age. Jscript is the most popular language and most RIA (which is the way web development is heading) depend on it, so i wouldn't be too concerned about it imho.
__________________
West Dorset Community |
|
|||
|
you are right i think jon123
i'm not that concerned now using ajax or javascript... its not bad actually. plus i didn't find any way around to make it using html+css i found some good sites around about dynamic design. cheers! ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
|
|