doudou3213 2015-12-12 21:59
浏览 26

在oscommerce中集成Wordpress帖子

I what to integrate a gallery from WordPress in to oscommerce. Now I am trying to make first, one menu with a list of posts names from data base that a "gallery type". The selection work fine and return the result. Now I try to integrate it in other php file from oscommerce but my result return only errors. Please help my to integrate my code into other code. This is the selection from data base and the returns from it.

<?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
?>

and the code where I what to integrate in it is

<?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');
    }
  }
?>

I need to integrate it some where in function

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);
    }
  • 写回答

1条回答 默认 最新

  • dongqiangse6623 2015-12-14 19:04
    关注

    I am not sure how you had integrated the WP environment into OSC or vise versa but to call WP functions in OSC you have to setup the WP environment first...for example, call this in your OSC application_top.php

    require('wp_dir/wp-load.php');
    

    It seems like you are making calls directly to WP, but I have been doing this by integrating WP into OSC, and then just using shortcodes to display stuffs I need from WP. I have couple WP/OSC examples online and I hope they can be helpful to you.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器