1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Embed custom header and footer

Discussion in 'Styling and Customization Questions' started by Slind, Dec 26, 2014.

  1. Slind

    Slind Active Member

    Hey,

    I would like to embed a custom header and footer. I would go about retrieving the data like this and putting it into a html file for caching.
    PHP:
    $data file_get_contents('http://site-with-header.com');

    $doc = new DOMDocument();
    $doc->loadHTML($data);
    $xpath = new DOMXpath($doc);
    $head $xpath->query("//head");
    $header $xpath->query("//header");
    $footer $xpath->query("//footer");

    function 
    domNodeList_to_string($DomNodeList) {
        
    $output '';
        
    $doc = new DOMDocument;
        while ( 
    $node $DomNodeList->item($i) ) {     
            
    $domNode $doc->importNode($nodetrue);
            
    $doc->appendChild($domNode);
            
    $i++;
        }
        
    $output $doc->saveHTML();
        
    $output print_r($output1);

        return 
    $output;
    }

    echo 
    domNodeList_to_string($head);
    echo 
    "<style type='text/css'> html {max-width: 960px; margin: auto;} </style>";
    echo 
    domNodeList_to_string($header);
    // Content
    echo domNodeList_to_string($footer);

    ?>
    Is there an easy way to include the output file as header/footer, so it is dynamically updated?
     
  2. Randall

    Randall Member

    I'm looking to do a similar thing. Did you ever find a solution?
     

Share This Page