Tring Web Design

Specialist Web Designers in the Tring Area, Berkhamsted, Bucks and Herts - info@tring-web-design.co.uk

Static header and footer from dynamic templates

  • Resources
  • cPanel Website Backups
  • Creating dynamic PDF files from PHP
  • Download Limit Monitoring Using IPCOP
  • Encrypt USB drives
  • E-Mail Newsletter Design
  • Exclude my visits from Google Analytics
  • Extract, Transform and Load
  • Forum Posts
  • Glossary of Terms
  • Imaging Hard Drives
  • Installing IPCOP as a firewall
  • PHP-GTK SWK Desktop Widgets
  • Pipe emails into a PHP script
  • Pure Rounded CSS3 Corners
  • SEO Basics
  • Speed up Xubuntu Boot Time
  • Sphider Tag Cloud
  • Static header and footer from dynamic templates

  • Suckerfish CMS Made Simple menus
  • Top of Google in 5 steps
  • Two Essential Web Design Tools - Firebug and Dust-me Selectors
  • Website Morphing
  • Watch
  • Music & Effects
  • Tools
  • When working with Content Management Systems, sometimes you would want to add a feature that works better then the one provided in your CMS. The problem of integrating the script into the look and feel arises, where the CMS spits out an ever changing dynamic template based pages, but your 3rd party script requires static headers and footer templates.

    Heres a dirty way of integrating 3rd party scripts into the look and feel of your site, basically what it does is read a page with a delimter in the content area, seperate into two strings, header and footer, then writes the strings to two files, header.html and footer.html. This has been designed to work with CMS Made Simple templates, but could be adapted to work with any other system. How well it scales up I do not know, you'll just have to try it and see...

    Step by step


    1. Create a new page within CMSMS, enter in the content area (less the quotes) "<delimeter>"

    2. Put the following code at the top of the 3rd party script php page you want headers and footers for

    function getContentOfURL($url){  
    $file = fopen($url, "r");
    if($file){
    while (!feof ($file)) {
    $line .= fread ($file, 1024*50);
    }
    return $line;
    }
    }


    function writeURL($filename, $content){

    // Change this path to where your scripts templates live
    $path = '/home/public_html/script/templates/' . $filename;

    if (!$handle = fopen($path, 'w')) { exit; }

    if (fwrite($handle, $content) === FALSE) { exit; }

    fclose($handle);
    }


    // Enter the location of the page created in step 1 above.
    // Note: I have URL rewriting on
    $string = getContentOfURL("http://www.domain.co.uk/3rdptytemplate.htm");

    $header = substr($string, 0, strpos($string, '<delimiter>'));
    $footer = strstr($string, '<delimiter>');

    // If your script uses different file names for headers and footers, change those here.
    $writeHeader = writeURL('header.html', $header);
    $writeFooter = writeURL('footer.html', $footer);

    3. Create two blank files, header.html and footer.html, upload them to the /script/templates/ directory, set permissions 777

    4. Run your script and it should work.

    I have used this on sphider, a php site search engine.

    New to content management or need some help using our system? View our video tutorials

    E-mail us or complete our requirements questionnaire for a more detailed quote

    Technical resources for web designers, developers and IT professionals

    Keep up-to-date with the projects we have been involved in

    Specialist web designers in Tring, Berkhamsted, Bucks and Herts

    info@tring-web-design.co.uk