0 down vote favorite
share [g+] share [fb] share [tw]
I’ve got a script put togheter form other sources, not my own thinking. The reason for me needing to get this to work is to get a drupal top menu into top of an opencart installation to be able to use the superior cms functionalites while letting opencart handle the superior web shop functions.
The problem is that the menu that prints to a cache file from the script uses relative url.s. This of course means that when the menu is required into opencart, which is on a subdomain, the paths show the path of the subdomain. Not good.
The code is as follows:
[php]<?php
$cache_time = 3600; // Time in seconds to keep a page cached
$cache_folder = ‘cache’; // Folder to store cached files (no trailing slash)
$cache_filename = $cache_folder.md5($_SERVER[‘REQUEST_URI’]);
// Location to lookup or store cached file
//Check to see if this file has already been cached
// If it has get and store the file creation time
$cache_created = (file_exists($cache_file_name)) ? filemtime($this->filename) : 0;
if ((time() - $cache_created) < $cache_time) {readfile($cache_filename);
// The cached copy is still valid, read it into the output buffer
die();
}
?>
?php ob_start(); // Turns on output buffering ?>
<?php $contents = ob_get_contents(); ?> <?php if ($page['header_menu']): ?>Also, it would be great to be able to get the cached file always be written to the same filename, otherwise it wouldn’t do much good since the menu in the shop would’t change when the drupal menu does since the change would result in a new filename.
I’ve looked at other questions here regarding drupal and absolute paths but either I don’t understand enough or they are not applicable. If the first, I apologize for taking up everybodys time for something I should’ve understood from what already is available.
Any help very much appreciated. Cheers!
/Thomas Lillieskold