Page header is very important and most powerful element when you are creating a new page or post. It is strictly advised that if you do not have enough knowledge in PHP programming please keep this option blank. Page headers are stored in a local PHP file at your server. When server request a page this header file is included after collecting information about that page and before any HTML code is generated. So here is the absolute or final control about your page; how it appears on the browser screen. You can tamper any information by using proper PHP code. Please do not generate any HTML code here.
Here are few possible and suggested uses of page header.
Here is an example of hotlink protected download page. Say, you have a download page download.html where you provide a download link of a zip file document.zip. You need to prevent any direct access of this zip file from other page or site. At the header of download.html file put the following line and save it.
<?php $_SESSION['download'] = 'on';?>
Now create another file download_zip.html. You need not fill any title, content or other fields because this page will never be displayed on browser screen. Now put the following code at the header field and save this file.
<?php
if((isset($_SESSION['download']))&&( $_SESSION['download']=='on')){
$filename='file.zip';
@header("Content-type: application/zip");
@header("Content-Disposition: attachment; filename=$filename");
echo @file_get_contents('document.zip');
exit;
}
else{header("Location: download.html");}
?>
You can use header field to switch title and other parameters with page number for a multipage document. An example of a three page document is given below.
<?php
$current_page=fw_get_querydata('fw_pageno');
switch($current_page){
case '1':
$fw_page_array['title']='Title1';
$fw_page_array['description']='Description1';
break;
case '1':
$fw_page_array['title']=' Title2';
$fw_page_array['description']=' Description2';
break;
case '1':
$fw_page_array['title']=' Title3';
$fw_page_array['description']=' Description3';
break;
default:
$fw_page_array['title']=' Title1';
$fw_page_array['description']=' Description1';
break;}
?>
Unlike page you can't use different templates for different post. But still you can manage to change your template by using header field. Say your default site template is simple and you want to use template colorful using header field. Use the following lines of code to do this.
<?php $fw_template_path = 'colorful'; ?>
If necessary you can conditionally or unconditionally redirect your page to a different URL using header field. To redirect a given page to another URL say http://differentdomain.com/pageone.html use the following code.
<?php header("Location: http://differentdomain.com/pageone.html"); ?>
To create a popup window first you add the following JavaScript code at the field 'Other head tag' of the page from where you want to open popup.
<script type="text/javascript">
<!--
function popup(){
window.open('popup.html','mypopup','width=300,height=350,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=yes');}
-->
</script>
Now put a link <a href="#" onclick="popup()">Open popup</a>
Whenever someone click the above link a popup window will appear displaying the page popup.html. Now you create a new page popup.html. Do not fill any field; just put following lines of code at the page header.
<html> <head> <title>Popup example</title> </head> <body> <p>Hello! This is an example of popup window.</p> <body></html> <?php exit; ?>
Now your popup window is ready to open.