首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在oscommerce中集成Wordpress帖子

在oscommerce中集成Wordpress帖子
EN

Stack Overflow用户
提问于 2015-12-13 05:59:52
回答 1查看 67关注 0票数 0

我想把一个画廊从WordPress集成到oscommerce中。现在我正在尝试首先,一个菜单与一个从数据库中的帖子名称列表,这是一个“画廊类型”。选择工作正常,并返回结果。现在我尝试将它集成到来自oscommerce的其他php文件中,但我的结果只返回错误。请帮助我将我的代码集成到其他代码中。这是从数据库中选择的内容和返回的内容。

代码语言:javascript
复制
<?php
//db parameters
$localhost = '####';
$db_username = '######';
$db_password = '#######';
$db_database = '1131496_class';

//connect to the database
mysql_connect($localhost, $db_username, $db_password);
@mysql_select_db($db_database) or die("Unable to select database");

//get data from database -- !
$query = "Select * FROM gall_posts WHERE post_type='bw_gallery' AND post_status='publish' ORDER BY id DESC";

$query_result = mysql_query($query);
$num_rows = mysql_numrows($query_result);

//close database connection
mysql_close();
?>
<?php
//start a loop
for($i=0; $i< $num_rows; $i++){

//assign data to variables, $i is the row number, which increases with each run of the loop
$blog_title = mysql_result($query_result, $i, "post_title");

echo '<li><a href="#">' .$blog_title. '</a></li>';

} //end the for loop
?>

以及代码中要集成的内容

代码语言:javascript
复制
<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2013 osCommerce

  Released under the GNU General Public License
*/

  class bm_gallery {
    var $code = 'bm_gallery';
    var $group = 'boxes';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function bm_gallery() {
      $this->title = MODULE_BOXES_GALLERY_TITLE;
      $this->description = MODULE_BOXES_GALLERY_DESCRIPTION;

      if ( defined('MODULE_BOXES_GALLERY_STATUS') ) {
        $this->sort_order = MODULE_BOXES_GALLERY_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_GALLERY_STATUS == 'True');

        $this->group = ((MODULE_BOXES_GALLERY_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right');
      }
    }

    function execute() {
      global $oscTemplate;

      $data = '<div class="ui-widget infoBoxContainer mj-information">' .
              '  <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_GALLERY_BOX_TITLE . '</div>' .
              '  <div class="ui-widget-content infoBoxContents">' .
              '    <p>Lesen Sie hier was unsere Kunden über uns sagen: </p>' .
              '    <a href="bewertungen.php">' . 'Alle Kundenmeinungen' . '</a><br />' .

              '  </div>' .
              '</div>';

      $oscTemplate->addBlock($data, $this->group);
    }

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_BOXES_GALLERY_STATUS');
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Information Module', 'MODULE_BOXES_GALLERY_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_GALLERY_CONTENT_PLACEMENT', 'Left Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_GALLERY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_BOXES_GALLERY_STATUS', 'MODULE_BOXES_GALLERY_CONTENT_PLACEMENT', 'MODULE_BOXES_GALLERY_SORT_ORDER');
    }
  }
?>

我需要在函数中的某个位置集成它

代码语言:javascript
复制
function execute() {
      global $oscTemplate;

      $data = '<div class="ui-widget infoBoxContainer mj-information">' .
              '  <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_GALLERY_BOX_TITLE . '</div>' .
              '  <div class="ui-widget-content infoBoxContents">' .
              '    <p>Lesen Sie hier was unsere Kunden über uns sagen: </p>' .
              '    <a href="bewertungen.php">' . 'Alle Kundenmeinungen' . '</a><br />' .

              '  </div>' .
              '</div>';

      $oscTemplate->addBlock($data, $this->group);
    }
EN

回答 1

Stack Overflow用户

发布于 2015-12-15 03:04:40

我不确定您是如何将WP环境集成到OSC中的,反之亦然,但要在OSC中调用WP函数,您必须设置WP环境first...for示例,在您的OSC application_top.php中调用此示例

代码语言:javascript
复制
require('wp_dir/wp-load.php');

看起来你是在直接打电话给WP,但我一直在做这件事,将WP集成到OSC中,然后使用短码来显示我从WP中需要的东西。我在网上有几个WP/OSC examples,我希望他们能对你有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34245489

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档