Jump to content

inserting page defaults


abhinavsingh89

Recommended Posts

I have a website which comprises of 35-40 pages. Now the problem with it is that if i have to modify a header or sidebar or footer in one page , than i have to change it in all the pages (as they are common in all the pages) i.e. 35-40 modification are required. What i want to do is centrally control the basic layout from a single file. Now i have no clue how to that as i am new to php. Can anybody help me regarding this??

thanks in advance

ABhinav

Link to comment
https://forums.phpfreaks.com/topic/185334-inserting-page-defaults/
Share on other sites

Have header.php and footer.php pages. Inside the header include the document declaration, <head> section, the opening <body> tag and any section at the top of the page that is on every page (header image, top menu, etc.). Footer will include the footer (well duh) and the closing of the </body> and </html> tags. In the header section for any meta tags/title you will simply put something along the lines of <title><?php echo $title; ?></title>. Then in each page you will do...

 

<?php
$title = 'Title for this page';
$description = 'Blah, we rock... blah';
$keywords = 'PHP, Freaks, Rock';

require 'header.php';
?>
<!-- Page content here -->
<?php require 'footer.php'; ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.