简体   繁体   English

在OpenCart中显示Wordpress菜单

[英]Display Wordpress Menu in OpenCart

I would like to display a Wordpress Menu in the OpenCart Header. 我想在OpenCart标头中显示Wordpress菜单。 In my test.php page I added the following code; 在我的test.php页面中,添加了以下代码;

<?php
require($_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php');  
wp_nav_menu( array( 'menu' => 'Test' ) ); ?>

And it works great, however when I add that into the header.tpl template in OpenCart I receive an error; 而且效果很好,但是当我将其添加到OpenCart的header.tpl模板中时,会收到错误消息。

Fatal error: Call to a member function get_queried_object() on a non-object in /....../wordpress/wp-includes/nav-menu-template.php on line 256

Can you assist? 你能帮忙吗? Have you done this before? 你以前做过吗? Seems that OpenCart is causing the problem? 似乎是OpenCart引起了问题?

APPENDED UPDATE ON PROGRESS BELOW 以下进度的追加更新

Okay, I have run default installations of OC and WP. 好的,我已经运行了OC和WP的默认安装。

Wordpress is in the root - www.test.local Opencart is in the root/store directory - www.test.local/store/ WordPress在根目录中-www.test.local Opencart在根目录/商店中-www.test.local / store /

In the Opencart Default Tenplate Header I have the following code: 在Opencart默认Tenplate标头中,我具有以下代码:

<?php $path = $_SERVER['DOCUMENT_ROOT'].'/wp-load.php';
      echo $path;
      require_once($path);  
      wp_nav_menu( array( 'menu' => 'Test' ) ); ?>

Which Generates the following error: 产生以下错误:

test.local/Sites/test.local/htdocs/wp-load.phpNotice: Constant DB_PASSWORD already defined in test.local/Sites/test.local/htdocs/wp-config.php on line 25Unknown: Redefining already defined constructor for class WP_Widget in test.local/Sites/test.local/htdocs/wp-includes/widgets.php on line 93Warning: strpos() expects parameter 1 to be string, array given in test.local/Sites/test.local/htdocs/wp-includes/functions.php on line 3048
Fatal error: Call to a member function get_queried_object() on a non-object in test.local/Sites/test.local/htdocs/wp-includes/nav-menu-template.php on line 256

Interestingly though, when I delete the 'Test' Menu from Wordpress, the menu displays in Opencart, However I still see the following error: 但是,有趣的是,当我从Wordpress中删除“测试”菜单时,该菜单在Opencart中显示,但是我仍然看到以下错误:

/Sites/test.local/htdocs/wp-load.phpNotice: Constant DB_PASSWORD already defined in /Sites/test.local/htdocs/wp-config.php on line 25Unknown: Redefining already defined constructor for class WP_Widget in /Sites/test.local/htdocs/wp-includes/widgets.php on line 93Warning: strpos() expects parameter 1 to be string, array given in /Sites/test.local/htdocs/wp-includes/functions.php on line 3048Notice: Trying to get property of non-object in /Sites/test.local/htdocs/wp-includes/post-template.php on line 845

A clue? 线索? Anyone got any ideas? 任何人有任何想法吗?

我相信您需要包括wp-blog-header.php而不是wp-load来看看这个http://www.problogdesign.com/wordpress/use-wordpress-as-a-php-framework-for -您-静态的HTML页/

The "Constant DB_PASSWORD already defined" is thrown because WP and OC use the same define variable for database password. 因为WP和OC对数据库密码使用相同的定义变量,所以将引发“已定义常数DB_PASSWORD”。 You need to change the OC DB_PASSWORD variable name to DB_PASSWORD_OC, and then in index.php change the following: 您需要将OC DB_PASSWORD变量名称更改为DB_PASSWORD_OC,然后在index.php中更改以下内容:

// Database //数据库

$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $ db =新的DB(DB_DRIVER,DB_HOSTNAME,DB_USERNAME,DB_PASSWORD,DB_DATABASE); ... ...

to comply with the new variable name: 符合新的变量名称:

// Database //数据库

$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD_OC, DB_DATABASE); $ db =新的DB(DB_DRIVER,DB_HOSTNAME,DB_USERNAME,DB_PASSWORD_OC,DB_DATABASE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM