mxdan Posted February 18, 2007 Share Posted February 18, 2007 Ok, so I had this code from a friend that divides the layout into top.html and bottom.html. In between is your different html pages and bringing it all together is the php code. It also makes the url look like: http://somename.com/index.php?page=content I lost one of the pages to allow me to do the php. But I have these php files: phpinfo.php pages.php utils.php The codes on the pages look like this: Pages.php <?php if ($_GET['page']!=""){ $load = $_GET['page']; } else{ $load = "$root_path/main.html"; } switch ($page){ // To add a page, copy text below. Past it right below the last entry at the bottom. case "[LINK NAME!]": $load = "$root_path/[PAGE URL NAME]"; break; // Delete [LINK NAME!] (with the brackets) and replace it with what the link name is. IE: "index.php?page=bananas" Replace it with "bananas" // Delete [PAGE URL NAME] and replace it with the actual page url. IE: if the actual page url is "animexe.com/bananas.html", then replace it as "bananas.html" //below this is the main pages utils.php <?php $root_url = "http://name.com"; $root_path = "."; ?> phpinfo.php <?php echo phpinfo() ?> _____________________________________________ The last code is for the top.html and bottom.html combining. Thanks in advanced =] Link to comment https://forums.phpfreaks.com/topic/39004-~~~-in-need-of-a-simple-php-code-~~~/ Share on other sites More sharing options...
mxdan Posted February 18, 2007 Author Share Posted February 18, 2007 I forgot to mention that the code starts up on the missing php code too. P.S. This post was mainly for bumping xD. Link to comment https://forums.phpfreaks.com/topic/39004-~~~-in-need-of-a-simple-php-code-~~~/#findComment-187809 Share on other sites More sharing options...
sspoke Posted February 18, 2007 Share Posted February 18, 2007 not much code to look at there but you just need to add top.html bottom.html and just in your index.php use <?=require("top.html"); ?> <?php //stuff ?> <?=require("bottom.html"); ?> Link to comment https://forums.phpfreaks.com/topic/39004-~~~-in-need-of-a-simple-php-code-~~~/#findComment-187812 Share on other sites More sharing options...
mxdan Posted February 18, 2007 Author Share Posted February 18, 2007 what goes in place of the //stuff part because I applied the code and all I get in the content part is a "1". Or do any of you know of a tutorial for this code? Link to comment https://forums.phpfreaks.com/topic/39004-~~~-in-need-of-a-simple-php-code-~~~/#findComment-187820 Share on other sites More sharing options...
corbin Posted February 18, 2007 Share Posted February 18, 2007 I suggest looking up GET and include(). I would just do something like: <?php $folder = "content/"; //folder to look for the html files in include("top.html"); //include the top $page = $_GET['page']; // set ?page= to $page $page = preg_replace("[^A-Za-z0-9\_\-\.]", "", $page); //replace anything thats not alphanumeric, -,_, or . with blankness if(file_exists($folder . $page . ".html")) { //if the file exists include($folder . $page . ".html"); //include the file } else { echo "Page Not Found"; //if it doesnt exist } include("bottom.html"); //include the bottom ?> Link to comment https://forums.phpfreaks.com/topic/39004-~~~-in-need-of-a-simple-php-code-~~~/#findComment-187828 Share on other sites More sharing options...
mxdan Posted February 18, 2007 Author Share Posted February 18, 2007 I'm a little lost as to how I would link that code. Could you go into further details? Link to comment https://forums.phpfreaks.com/topic/39004-~~~-in-need-of-a-simple-php-code-~~~/#findComment-187852 Share on other sites More sharing options...
mxdan Posted February 18, 2007 Author Share Posted February 18, 2007 Or better yet, can you explain how I would incorperate the pages.php file into that code? =/ Link to comment https://forums.phpfreaks.com/topic/39004-~~~-in-need-of-a-simple-php-code-~~~/#findComment-188239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.