Hello all... Thanks in advance for your feedback!
THE ISSUE. My OpenCart shop (v1.5.2.1) is a sub-directory of my main website. I would like to use the OpenCart header as the header on the pages of the main site.
How do I pull (i.e integrate) the OC header into the external pages of the main site?
I'm an OpenCart novice and new to the forum... and welcome your input.
THE ISSUE. My OpenCart shop (v1.5.2.1) is a sub-directory of my main website. I would like to use the OpenCart header as the header on the pages of the main site.
How do I pull (i.e integrate) the OC header into the external pages of the main site?
I'm an OpenCart novice and new to the forum... and welcome your input.
create a header for your other site , that looks like opencart's.I dont think you would be able to pull it.
Not impossible at all!
Depends how in-depth you want to go.
It wouldn't be too hard to make a controller which loads up the template for you. The best way would be to make your own controller, it's not as hard as you think! The controller could load up another php page if you want or you could copy and paste into this controller, however you want to do it.
A quick go, untested but should work.
/catalog/controller/mypages/testpage.php
/catalog/controller/common/blank.tpl
index.php?route=mypages/testpage
Depends how in-depth you want to go.
It wouldn't be too hard to make a controller which loads up the template for you. The best way would be to make your own controller, it's not as hard as you think! The controller could load up another php page if you want or you could copy and paste into this controller, however you want to do it.
A quick go, untested but should work.
/catalog/controller/mypages/testpage.php
Code: Select all
<?php
class ControllerMypagesTestpage extends Controller {
public function index() {
$this->document->setTitle($this->config->get('config_title'));
$this->document->setDescription($this->config->get('config_meta_description'));
$this->data['heading_title'] = 'My Page Title';
$this->data['page_content'] = 'whatever you want your page to be';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/blank.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/blank.tpl';
} else {
$this->template = 'default/template/common/blank.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
}
?>
Code: Select all
<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
<h1 style="display: none;"><?php echo $heading_title; ?></h1>
<?php echo $page_content; ?>
<?php echo $content_bottom; ?></div>
<?php echo $footer; ?>
Thanks smifis!
It's been an effort trying to pull the default header in OC --
mysite.com/shop/catalog/controller/common/header.php
...into my main site pages (located outside the OC shop).
Example; mysite.com/page.php1, mysite.com/page2.php, etc.
I'll try your suggestion.
P.S. Additional tips or optional solutions still welcome...
It's been an effort trying to pull the default header in OC --
mysite.com/shop/catalog/controller/common/header.php
...into my main site pages (located outside the OC shop).
Example; mysite.com/page.php1, mysite.com/page2.php, etc.
I'll try your suggestion.
P.S. Additional tips or optional solutions still welcome...
I think what you're finding quite difficult is addressing all of the variables in the header file.
Perhaps if you include the page content into a variable, you could then include it into a controller file and include opencart at the end of each file to template it.
Perhaps if you include the page content into a variable, you could then include it into a controller file and include opencart at the end of each file to template it.
Thanks for your help on this smithis... And everyone else that offered their input.
Here's what finally worked... Compliments of http://www.Viteb.com
Given your existing pages:
yoursite.com/page.php (i.e. your page outside the shop),
yoursite.com/shop/catalog/controller/common/header.php -and-
yoursite/shop/catalog/view/theme/default/template/common/header.tpl
1. Create file headerXYZ.php using the following code and save it to the root directory of your main site (or other location of your choosing outside your OC shop).
2. Now, include headerXYZ.php in page.php i.e. Place the statement below on line 1 at the very top of page.php
3. Finally, right after the opening body tag of your external page.php page add the following list of statements
That's it... You're done! You should now have a fully functional header (with working cart, login, etc.) in your page located outside of your Opencart shop.
SIDE NOTE: You could also just plug the entire code (including the content of headerXYZ.php and the 13 require_once statements) directly into the your external page.
Hope someone will find this solution useful. Thanks again everyone!
Here's what finally worked... Compliments of http://www.Viteb.com
Given your existing pages:
yoursite.com/page.php (i.e. your page outside the shop),
yoursite.com/shop/catalog/controller/common/header.php -and-
yoursite/shop/catalog/view/theme/default/template/common/header.tpl
1. Create file headerXYZ.php using the following code and save it to the root directory of your main site (or other location of your choosing outside your OC shop).
Code: Select all
<?php
// Config
require_once('shop/config.php');
// VirtualQMOD
require_once('shop/vqmod/vqmod.php');
$vqmod = new VQMod();
// VQMODDED Startup
require_once($vqmod->modCheck(DIR_SYSTEM . 'startup.php'));
// Application Classes
require_once($vqmod->modCheck(DIR_SYSTEM . 'library/customer.php'));
require_once($vqmod->modCheck(DIR_SYSTEM . 'library/affiliate.php'));
require_once($vqmod->modCheck(DIR_SYSTEM . 'library/currency.php'));
require_once($vqmod->modCheck(DIR_SYSTEM . 'library/tax.php'));
require_once($vqmod->modCheck(DIR_SYSTEM . 'library/weight.php'));
require_once($vqmod->modCheck(DIR_SYSTEM . 'library/length.php'));
require_once($vqmod->modCheck(DIR_SYSTEM . 'library/cart.php'));
$myVar = array();
$myVar = array();
// Registry
$registry = new Registry();
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// Url
$url = new Url($config->get('config_url'), $config->get('config_use_ssl') ? $config->get('config_ssl') :
$config->get('config_url'));
$registry->set('url', $url);
// Log
$log = new Log($config->get('config_error_filename'));
$registry->set('log', $log);
function error_handler($errno, $errstr, $errfile, $errline) {
global $log, $config;
switch ($errno) {
case E_NOTICE:
case E_USER_NOTICE:
$error = 'Notice';
break;
case E_WARNING:
case E_USER_WARNING:
$error = 'Warning';
break;
case E_ERROR:
case E_USER_ERROR:
$error = 'Fatal Error';
break;
default:
$error = 'Unknown';
break;
}
if ($config->get('config_error_display')) {
echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>';
}
if ($config->get('config_error_log')) {
$log->write('PHP ' . $error . ': ' . $errstr . ' in ' . $errfile . ' on line ' . $errline);
}
return true;
}
// Error Handler
set_error_handler('error_handler');
// Request
$request = new Request();
$registry->set('request', $request);
// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);
// Cache
$cache = new Cache();
$registry->set('cache', $cache);
// Session
$session = new Session();
$registry->set('session', $session);
// Language Detection
$languages = array();
$query = $db->query("SELECT * FROM " . DB_PREFIX . "language");
foreach ($query->rows as $result) {
$languages[$result['code']] = $result;
}
$detect = '';
if (isset($request->server['HTTP_ACCEPT_LANGUAGE']) && ($request->server['HTTP_ACCEPT_LANGUAGE'])) {
$browser_languages = explode(',', $request->server['HTTP_ACCEPT_LANGUAGE']);
foreach ($browser_languages as $browser_language) {
foreach ($languages as $key => $value) {
if ($value['status']) {
$locale = explode(',', $value['locale']);
if (in_array($browser_language, $locale)) {
$detect = $key;
}
}
}
}
}
if (isset($request->get['language']) && array_key_exists($request->get['language'], $languages) &&
$languages[$request->get['language']]['status']) {
$code = $request->get['language'];
} elseif (isset($session->data['language']) && array_key_exists($session->data['language'], $languages)) {
$code = $session->data['language'];
} elseif (isset($request->cookie['language']) && array_key_exists($request->cookie['language'], $languages)) {
$code = $request->cookie['language'];
} elseif ($detect) {
$code = $detect;
} else {
$code = $config->get('config_language');
}
if (!isset($session->data['language']) || $session->data['language'] != $code) {
$session->data['language'] = $code;
}
if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) {
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']);
}
$config->set('config_language_id', $languages[$code]['language_id']);
$config->set('config_language', $languages[$code]['code']);
// Language
$language = new Language($languages[$code]['directory']);
$language->load($languages[$code]['filename']);
$registry->set('language', $language);
// Document
$document = new Document();
$registry->set('document', $document);
// Customer
$registry->set('customer', new Customer($registry));
// Affiliate
$affiliate = new Affiliate($registry);
$registry->set('affiliate', $affiliate);
if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) {
setcookie('tracking', $request->get['tracking'], time() + 3600 * 24 * 1000, '/');
}
// Currency
$registry->set('currency', new Currency($registry));
// Tax
$tax = new Tax($registry);
$registry->set('tax', $tax);
// Weight
$registry->set('weight', new Weight($registry));
// Length
$registry->set('length', new Length($registry));
// Cart
$registry->set('cart', new Cart($registry));
// Front Controller
$controller = new Front($registry);
// Maintenance Mode
$controller->addPreAction(new Action('common/maintenance'));
// SEO URL's
$controller->addPreAction(new Action('common/seo_url'));
// Router
if (isset($request->get['route'])) {
$action = new Action($request->get['route']);
} else {
$action = new Action('common/home');
}
// Dispatch
$controller->dispatch($action, new Action('error/not_found'));
Code: Select all
<?php require_once ('headerXYZ.php');?>
Code: Select all
<?php
require_once('shop/catalog/model/total/sub_total.php');
require_once('shop/catalog/language/english/total/sub_total.php');
require_once('shop/catalog/model/total/reward.php');
require_once('shop/catalog/model/total/shipping.php');
require_once('shop/catalog/model/total/coupon.php');
require_once('shop/catalog/model/total/tax.php');
require_once('shop/catalog/model/total/credit.php');
require_once('shop/catalog/language/english/total/credit.php');
require_once('shop/catalog/model/total/voucher.php');
require_once('shop/catalog/model/total/total.php');
require_once('shop/catalog/language/english/total/total.php');
foreach($myVar as $key=>$value)
{
$$key = $value;
}
require_once('shop/catalog/controller/common/header.php');
require_once('shop/catalog/view/theme/default/template/common/header.tpl');
?>
SIDE NOTE: You could also just plug the entire code (including the content of headerXYZ.php and the 13 require_once statements) directly into the your external page.
Hope someone will find this solution useful. Thanks again everyone!
Last edited by dEdge on Tue Apr 17, 2012 7:59 pm, edited 1 time in total.
Hi dEdge
Tried your above method exactly (I hope) but get the following error:
Fatal error: Class 'Model' not found in /home/******/public_html/******/shop/catalog/model/total/sub_total.php on line 2
Do you have any ideas please?
v1.5.2.1 + vQmod
Tried your above method exactly (I hope) but get the following error:
Fatal error: Class 'Model' not found in /home/******/public_html/******/shop/catalog/model/total/sub_total.php on line 2
Do you have any ideas please?
v1.5.2.1 + vQmod
Sorry for the late response davetest. Try using the relative path to headerXYZ.php instead of the absolute path.
For example, use relative path below instead of absolute path <?php require_once ('http://www.yoursite.com/headerXYZ.php');?>
Correction updated in Step #2
For example, use relative path below instead of absolute path <?php require_once ('http://www.yoursite.com/headerXYZ.php');?>
Code: Select all
<?php require_once ('headerXYZ.php');?>
Hi dEdge
Thanks last tip got me forward, but now getting:
Fatal error: Cannot redeclare class ControllerCommonHeader in /home/******/public_html/shop/catalog/controller/common/header.php on line 117
Do you have any ideas please?
I'm using 1.5.2.1
Thanks
Thanks last tip got me forward, but now getting:
Fatal error: Cannot redeclare class ControllerCommonHeader in /home/******/public_html/shop/catalog/controller/common/header.php on line 117
Do you have any ideas please?
I'm using 1.5.2.1
Thanks
I followed exactly what is mentioned; my site doesn't have shop but instead I have installed cart under tempcart so I have changed that too.dEdge wrote:Thanks for your help on this smithis... And everyone else that offered their input.
Here's what finally worked... Compliments of http://www.Viteb.com
Given your existing pages:
yoursite.com/page.php (i.e. your page outside the shop),
yoursite.com/shop/catalog/controller/common/header.php -and-
yoursite/shop/catalog/view/theme/default/template/common/header.tpl
1. Create file headerXYZ.php using the following code and save it to the root directory of your main site (or other location of your choosing outside your OC shop).
2. Now, include headerXYZ.php in page.php i.e. Place the statement below on line 1 at the very top of page.phpCode: Select all
<?php // Config require_once('shop/config.php'); // VirtualQMOD require_once('shop/vqmod/vqmod.php'); $vqmod = new VQMod(); // VQMODDED Startup require_once($vqmod->modCheck(DIR_SYSTEM . 'startup.php')); // Application Classes require_once($vqmod->modCheck(DIR_SYSTEM . 'library/customer.php')); require_once($vqmod->modCheck(DIR_SYSTEM . 'library/affiliate.php')); require_once($vqmod->modCheck(DIR_SYSTEM . 'library/currency.php')); require_once($vqmod->modCheck(DIR_SYSTEM . 'library/tax.php')); require_once($vqmod->modCheck(DIR_SYSTEM . 'library/weight.php')); require_once($vqmod->modCheck(DIR_SYSTEM . 'library/length.php')); require_once($vqmod->modCheck(DIR_SYSTEM . 'library/cart.php')); $myVar = array(); $myVar = array(); // Registry $registry = new Registry(); // Loader $loader = new Loader($registry); $registry->set('load', $loader); // Config $config = new Config(); $registry->set('config', $config); // Database $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $registry->set('db', $db); // Url $url = new Url($config->get('config_url'), $config->get('config_use_ssl') ? $config->get('config_ssl') : $config->get('config_url')); $registry->set('url', $url); // Log $log = new Log($config->get('config_error_filename')); $registry->set('log', $log); function error_handler($errno, $errstr, $errfile, $errline) { global $log, $config; switch ($errno) { case E_NOTICE: case E_USER_NOTICE: $error = 'Notice'; break; case E_WARNING: case E_USER_WARNING: $error = 'Warning'; break; case E_ERROR: case E_USER_ERROR: $error = 'Fatal Error'; break; default: $error = 'Unknown'; break; } if ($config->get('config_error_display')) { echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>'; } if ($config->get('config_error_log')) { $log->write('PHP ' . $error . ': ' . $errstr . ' in ' . $errfile . ' on line ' . $errline); } return true; } // Error Handler set_error_handler('error_handler'); // Request $request = new Request(); $registry->set('request', $request); // Response $response = new Response(); $response->addHeader('Content-Type: text/html; charset=utf-8'); $response->setCompression($config->get('config_compression')); $registry->set('response', $response); // Cache $cache = new Cache(); $registry->set('cache', $cache); // Session $session = new Session(); $registry->set('session', $session); // Language Detection $languages = array(); $query = $db->query("SELECT * FROM " . DB_PREFIX . "language"); foreach ($query->rows as $result) { $languages[$result['code']] = $result; } $detect = ''; if (isset($request->server['HTTP_ACCEPT_LANGUAGE']) && ($request->server['HTTP_ACCEPT_LANGUAGE'])) { $browser_languages = explode(',', $request->server['HTTP_ACCEPT_LANGUAGE']); foreach ($browser_languages as $browser_language) { foreach ($languages as $key => $value) { if ($value['status']) { $locale = explode(',', $value['locale']); if (in_array($browser_language, $locale)) { $detect = $key; } } } } } if (isset($request->get['language']) && array_key_exists($request->get['language'], $languages) && $languages[$request->get['language']]['status']) { $code = $request->get['language']; } elseif (isset($session->data['language']) && array_key_exists($session->data['language'], $languages)) { $code = $session->data['language']; } elseif (isset($request->cookie['language']) && array_key_exists($request->cookie['language'], $languages)) { $code = $request->cookie['language']; } elseif ($detect) { $code = $detect; } else { $code = $config->get('config_language'); } if (!isset($session->data['language']) || $session->data['language'] != $code) { $session->data['language'] = $code; } if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) { setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']); } $config->set('config_language_id', $languages[$code]['language_id']); $config->set('config_language', $languages[$code]['code']); // Language $language = new Language($languages[$code]['directory']); $language->load($languages[$code]['filename']); $registry->set('language', $language); // Document $document = new Document(); $registry->set('document', $document); // Customer $registry->set('customer', new Customer($registry)); // Affiliate $affiliate = new Affiliate($registry); $registry->set('affiliate', $affiliate); if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) { setcookie('tracking', $request->get['tracking'], time() + 3600 * 24 * 1000, '/'); } // Currency $registry->set('currency', new Currency($registry)); // Tax $tax = new Tax($registry); $registry->set('tax', $tax); // Weight $registry->set('weight', new Weight($registry)); // Length $registry->set('length', new Length($registry)); // Cart $registry->set('cart', new Cart($registry)); // Front Controller $controller = new Front($registry); // Maintenance Mode $controller->addPreAction(new Action('common/maintenance')); // SEO URL's $controller->addPreAction(new Action('common/seo_url')); // Router if (isset($request->get['route'])) { $action = new Action($request->get['route']); } else { $action = new Action('common/home'); } // Dispatch $controller->dispatch($action, new Action('error/not_found'));
3. Finally, right after the opening body tag of your external page.php page add the following list of statementsCode: Select all
<?php require_once ('headerXYZ.php');?>
That's it... You're done! You should now have a fully functional header (with working cart, login, etc.) in your page located outside of your Opencart shop.Code: Select all
<?php require_once('shop/catalog/model/total/sub_total.php'); require_once('shop/catalog/language/english/total/sub_total.php'); require_once('shop/catalog/model/total/reward.php'); require_once('shop/catalog/model/total/shipping.php'); require_once('shop/catalog/model/total/coupon.php'); require_once('shop/catalog/model/total/tax.php'); require_once('shop/catalog/model/total/credit.php'); require_once('shop/catalog/language/english/total/credit.php'); require_once('shop/catalog/model/total/voucher.php'); require_once('shop/catalog/model/total/total.php'); require_once('shop/catalog/language/english/total/total.php'); foreach($myVar as $key=>$value) { $$key = $value; } require_once('shop/catalog/controller/common/header.php'); require_once('shop/catalog/view/theme/default/template/common/header.tpl'); ?>
SIDE NOTE: You could also just plug the entire code (including the content of headerXYZ.php and the 13 require_once statements) directly into the your external page.
Hope someone will find this solution useful. Thanks again everyone!
But instead of cart I get following on top of my page
Code: Select all
$value) { $$key = $value; } require_once('tempcart/catalog/controller/common/header.php'); require_once('tempcart/catalog/view/theme/default/template/common/header.tpl'); ?>
Thanks dEdge! I was thinking about doing this myself but luckily I found this topic. It's exactly what I need.
I'll try to check if this still works within a few days and report back. Can't see why it should not work though
I'll try to check if this still works within a few days and report back. Can't see why it should not work though

Im looking to do this exact thing, but alas im coming up against an error, which I do not appear to have a answer to
Is this due to the orginal code now being dated?
Fatal error: Cannot instantiate abstract class VQMod in /Users/matthiscock/Sites/senses/uber/headerXYZ.php on line 7
any ideas would be awesome
Is this due to the orginal code now being dated?
Fatal error: Cannot instantiate abstract class VQMod in /Users/matthiscock/Sites/senses/uber/headerXYZ.php on line 7
any ideas would be awesome
http://www.senses.co.uk
Senses Web Soltuions
Latest Releases:
http://www.personalisedcanvas.com/
http://www.stampedelytham.co.uk/
Hi All
Ive just finished an integration.
I wasnt over the moon with the example above, mainly as due to various changes with VQ Mod it no longer works! Also there were plenty of other issues, and I needed a little more.
My integration can cope with:
- Shopping cart drop down (on many themes) to show items
- SEO Links (yes, its in there!)
- Navigations which have categories and brands in them
Also it works the other way, so you can have wordpress posts in operncart pages! Nice.
I might be tempted to release it, if people are interested (probably a pay module, as the support take time!) but relly just seeing if there is demand.
Ill post a link to the site once it has launched, or if I forget, please feel free to email me on matt@s3d.co.uk
BTW - No core files are over written. The only minor one is one line added to the wordpress index.php (which has not changed in years, so not sure if it is classed as core!)
Developed on 1.5.x but I do not see a reason why this would break on older and (hopefully) newer versions
Matt
Ive just finished an integration.
I wasnt over the moon with the example above, mainly as due to various changes with VQ Mod it no longer works! Also there were plenty of other issues, and I needed a little more.
My integration can cope with:
- Shopping cart drop down (on many themes) to show items
- SEO Links (yes, its in there!)
- Navigations which have categories and brands in them
Also it works the other way, so you can have wordpress posts in operncart pages! Nice.
I might be tempted to release it, if people are interested (probably a pay module, as the support take time!) but relly just seeing if there is demand.
Ill post a link to the site once it has launched, or if I forget, please feel free to email me on matt@s3d.co.uk
BTW - No core files are over written. The only minor one is one line added to the wordpress index.php (which has not changed in years, so not sure if it is classed as core!)
Developed on 1.5.x but I do not see a reason why this would break on older and (hopefully) newer versions
Matt
http://www.senses.co.uk
Senses Web Soltuions
Latest Releases:
http://www.personalisedcanvas.com/
http://www.stampedelytham.co.uk/
I need help with this problem exactly. I followed the instruction. I'm on OC 1.4.9.4 (not by choice) and don't have vqmod. I had to tune up the header a bit, but I have this:
(Comments are code I removed because it returned errors).
I also added this at the top of my index.php file. Once again, commented line were giving errors (files don't exist)
I can use my header.tpl , but the tool variable ($cart, $account, $checkout, $logout) still won't work. I also noticed there's an array called $myVar, but I didn't find anything giving it any value, but the foreach seems like it would give the values to the tool variables.
Anyone can help me with that? Thanks
(Comments are code I removed because it returned errors).
Code: Select all
<?php
// Version
// Configuration
require_once('config.php');
// Install
if (!defined('DIR_APPLICATION')) {
header('Location: install/index.php');
exit;
}
// Startup
require_once(DIR_SYSTEM . 'startup.php');
// Application Classes
require_once(DIR_SYSTEM . 'library/customer.php');
require_once(DIR_SYSTEM . 'library/currency.php');
require_once(DIR_SYSTEM . 'library/tax.php');
require_once(DIR_SYSTEM . 'library/weight.php');
require_once(DIR_SYSTEM . 'library/length.php');
require_once(DIR_SYSTEM . 'library/cart.php');
$myVar = array();
// Registry
$registry = new Registry();
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// Settings
#$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting");
#foreach ($query->rows as $setting) {
# $config->set($setting['key'], $setting['value']);
#}
// Store
$query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE url = '" . $db->escape('http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "' OR url = '" . $db->escape('http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
foreach ($query->row as $key => $value) {
$config->set('config_' . $key, $value);
}
define('HTTP_SERVER', $config->get('config_url'));
define('HTTP_IMAGE', HTTP_SERVER . 'image/');
if ($config->get('config_ssl')) {
define('HTTPS_SERVER', 'https://' . substr($config->get('config_url'), 7));
define('HTTPS_IMAGE', HTTPS_SERVER . 'image/');
} else {
define('HTTPS_SERVER', HTTP_SERVER);
define('HTTPS_IMAGE', HTTP_IMAGE);
}
// Log
$log = new Log($config->get('config_error_filename'));
$registry->set('log', $log);
function error_handler($errno, $errstr, $errfile, $errline) {
global $log, $config;
switch ($errno) {
case E_NOTICE:
case E_USER_NOTICE:
$error = 'Notice';
break;
case E_WARNING:
case E_USER_WARNING:
$error = 'Warning';
break;
case E_ERROR:
case E_USER_ERROR:
$error = 'Fatal Error';
break;
default:
$error = 'Unknown';
break;
}
if ($config->get('config_error_display')) {
echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>';
}
if ($config->get('config_error_log')) {
$log->write('PHP ' . $error . ': ' . $errstr . ' in ' . $errfile . ' on line ' . $errline);
}
return true;
}
// Error Handler
set_error_handler('error_handler');
// Request
$request = new Request();
$registry->set('request', $request);
// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
#$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);
// Cache
$cache = new Cache();
$registry->set('cache', $cache);
// Session
$session = new Session();
$registry->set('session', $session);
// Language Detection
$languages = array();
$query = $db->query("SELECT * FROM " . DB_PREFIX . "language");
foreach ($query->rows as $result) {
$languages[$result['code']] = $result;
}
$detect = '';
if (isset($request->server['HTTP_ACCEPT_LANGUAGE']) && ($request->server['HTTP_ACCEPT_LANGUAGE'])) {
$browser_languages = explode(',', $request->server['HTTP_ACCEPT_LANGUAGE']);
foreach ($browser_languages as $browser_language) {
foreach ($languages as $key => $value) {
if ($value['status']) {
$locale = explode(',', $value['locale']);
if (in_array($browser_language, $locale)) {
$detect = $key;
}
}
}
}
}
if (isset($request->get['language']) && array_key_exists($request->get['language'], $languages) && $languages[$request->get['language']]['status']) {
$code = $request->get['language'];
} elseif (isset($session->data['language']) && array_key_exists($session->data['language'], $languages)) {
$code = $session->data['language'];
} elseif (isset($request->cookie['language']) && array_key_exists($request->cookie['language'], $languages)) {
$code = $request->cookie['language'];
} elseif ($detect) {
$code = $detect;
} else {
$code = $config->get('config_language');
}
if (!isset($session->data['language']) || $session->data['language'] != $code) {
$session->data['language'] = $code;
}
if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) {
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']);
}
$config->set('config_language_id', $languages[$code]['language_id']);
$config->set('config_language', $languages[$code]['code']);
// Language
$language = new Language($languages[$code]['directory']);
$language->load($languages[$code]['filename']);
$registry->set('language', $language);
// Document
$document = new Document();
$registry->set('document', $document);
// Customer
$registry->set('customer', new Customer($registry));
// Affiliate
#$affiliate = new Affiliate($registry);
#$registry->set('affiliate', $affiliate);
if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) {
setcookie('tracking', $request->get['tracking'], time() + 3600 * 24 * 1000, '/');
}
// Language
$language = new Language($languages[$code]['directory']);
$language->load($languages[$code]['filename']);
$registry->set('language', $language);
// Customer
$registry->set('customer', new Customer($registry));
// Currency
$registry->set('currency', new Currency($registry));
// Tax
$registry->set('tax', new Tax($registry));
// Weight
$registry->set('weight', new Weight($registry));
// Length
$registry->set('length', new Length($registry));
// Cart
$registry->set('cart', new Cart($registry));
// Front Controller
$controller = new Front($registry);
// Maintenance Mode
$controller->addPreAction(new Action('common/maintenance/check'));
// SEO URL's
$controller->addPreAction(new Action('common/seo_url'));
// Router
if (isset($request->get['route'])) {
$action = new Action($request->get['route']);
} else {
$action = new Action('common/home');
}
// Dispatch
$controller->dispatch($action, new Action('error/not_found'));
Code: Select all
<?php
require_once('catalog/model/total/sub_total.php');
require_once('catalog/language/'.$language_long.'/total/sub_total.php');
#require_once('catalog/model/total/reward.php');
require_once('catalog/model/total/shipping.php');
require_once('catalog/model/total/coupon.php');
require_once('catalog/model/total/tax.php');
#require_once('catalog/model/total/credit.php');
#require_once('catalog/language/'.$language_long.'/total/credit.php');
#require_once('catalog/model/total/voucher.php');
require_once('catalog/model/total/total.php');
require_once('catalog/language/'.$language_long.'/total/total.php');
foreach($myVar as $key=>$value)
{
$$key = $value;
}
require_once('catalog/controller/common/header.php');
require_once('catalog/view/theme/broderie/template/common/header.tpl');
?>
Anyone can help me with that? Thanks
Okay, I will redefine my problem, maybe someone will be able to help. I'll make this simple:
I can't use the values defined in the controller.
I mean, header.tpl can use $shopping_cart because of $this->data['shopping_cart'], but even with the headerXYZ.php, I can't get the values. Why? Thanks.
I can't use the values defined in the controller.
I mean, header.tpl can use $shopping_cart because of $this->data['shopping_cart'], but even with the headerXYZ.php, I can't get the values. Why? Thanks.
Hi,
Okay I have followed the directions above. I have vqmod 2.4.1 for opencart installed on my server, and running opencart 1.5.6. I have also created headerXYZ.php and installed to my root file.
For what ever reason when I install the codes to the header and to the opening body of my .php pages; upload and refresh the page, the page is blank.
Any Idea how I should proceed?
Thanks
Okay I have followed the directions above. I have vqmod 2.4.1 for opencart installed on my server, and running opencart 1.5.6. I have also created headerXYZ.php and installed to my root file.
For what ever reason when I install the codes to the header and to the opening body of my .php pages; upload and refresh the page, the page is blank.
Any Idea how I should proceed?
Thanks
Hi,
Resurrecting an old thread. but am working with above solution and hence did not feel like creating a new post for the same issue.
I got the header (or rather the entire opencart home page) into wordpress. However, at the end of the page, I get the below error. Any idea what is this? I am using the 1.5.6x version of opencart with latest version of wordpress.
Kindly help me in getting this fixed.
Thanks,
Praveen
Resurrecting an old thread. but am working with above solution and hence did not feel like creating a new post for the same issue.
I got the header (or rather the entire opencart home page) into wordpress. However, at the end of the page, I get the below error. Any idea what is this? I am using the 1.5.6x version of opencart with latest version of wordpress.
Code: Select all
Fatal error: Cannot redeclare class ControllerCommonHeader in /home1/***/public_html/***/store/catalog/controller/common/header.php on line 152
Thanks,
Praveen
Who is online
Users browsing this forum: No registered users and 5 guests