July 12, 201115 yr My site is sort of laid out in the following way; Header - including menus and login etc Main section - main part of the site content Footer - including links etc For different pages such as member page, profile page, should I create a whole new page with each page having the header, main and footer, or on the index.php main section should i put an 'if' statement into the coding that displays the different pages only in this section? I'm not sure which I should use, I hope this makes sense to you, let me know if not.
July 12, 201115 yr My site is sort of laid out in the following way; Header - including menus and login etc Main section - main part of the site content Footer - including links etc For different pages such as member page, profile page, should I create a whole new page with each page having the header, main and footer, or on the index.php main section should i put an 'if' statement into the coding that displays the different pages only in this section? I'm not sure which I should use, I hope this makes sense to you, let me know if not. You should really only use if statements for minor differences. When the whole page etc is going to be different, stick to templates.
July 12, 201115 yr If it was me I would create 2 include files one for the header and one for the footer then just call them on each page. so you would do something like this for each of your pages: <?php require_once($_Server["DOCUMENT_ROOT"] . /Path/To/header.inc ); ?> Content goes here <?php require_once($_Server["DOCUMENT_ROOT"] . /Path/To/footer.inc ); ?> the header.inc and footer.inc files are fine to have html or php in them. Hope that makes sense Ysuran
July 12, 201115 yr Both good answers. Do not use major bulks of content within if statements. Switch to using includes as stated above. and include the file where it would normally reside in the code.
July 12, 201115 yr Author that's how I have it laid out at the moment. <?php require('header.php'); require('main.php'); require('footer.php'); ?> Should I have them stored as .php files or .inc files? Don't .inc files get shown as text if someone was able to access them at all?
July 13, 201115 yr .php files are fine. You are right .inc files will show as text. I always set it up so they aren't publicly viewable but it really is a matter of choice I guess.
Create an account or sign in to comment