Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to create a new module box question


bluesaber84

Recommended Posts

Hello all!  I am using version 2.3.4. How can i make my own box (modules, boxes) to put my own content in the box such as a picture or video. Just like a box for new arrivals which is already there, but a box like the latest news or something. I have tried to modify a box that i do not use and customize it but cant seem to figure it out. any help here? I hope this question make sense...

Link to comment
Share on other sites

and / or even on the main home page where the "new products for <insert current month> is default with all of your current new products, can that be customized or deleted and add your own video or pic, etc....

Link to comment
Share on other sites

Create a new file catalog/includes/modules/boxes/bm_newbox.php

Copy this information into it, and add your logic and/or data in the line indicated

<?php
/*
  $Id$

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

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

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

    function bm_newbox() {
      $this->title = MODULE_BOXES_NEWBOX_TITLE;
      $this->description = MODULE_BOXES_NEWBOX_DESCRIPTION;

      if ( defined('MODULE_BOXES_NEWBOX_STATUS') ) {
        $this->sort_order = MODULE_BOXES_NEWBOX_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_NEWBOX_STATUS == 'True');

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

    function execute() {
      global $oscTemplate;

      $data = 'YOUR LOGIC AND/OR DATA GOES HERE';

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

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

    function check() {
      return defined('MODULE_BOXES_NEWBOX_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 New Box Module', 'MODULE_BOXES_NEWBOX_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_NEWBOX_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_NEWBOX_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_NEWBOX_STATUS', 'MODULE_BOXES_NEWBOX_CONTENT_PLACEMENT', 'MODULE_BOXES_NEWBOX_SORT_ORDER');
    }
  }
?>

Create a new file called catalog\includes\languages\english\modules\boxes\bm_newbox.php and copy the following into it:

<?php
/*
  $Id$

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

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  define('MODULE_BOXES_NEWBOX_TITLE', 'New Box');
  define('MODULE_BOXES_NEWBOX_DESCRIPTION', 'Show New Box');
  define('MODULE_BOXES_NEWBOX_BOX_TITLE', 'New Box');
?>

You can change or add any definitions you need to.

Go to admin -> Modules -> Boxes -> Install Module and install your new box.

osCommerce user since 2003! :thumbsup:

Link to comment
Share on other sites

For the new products, open catalog/index.php and change the following line

include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);

to

//include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);

then below the ?> add 

<div>
  YOUR NEW CONTENT HERE
</div>

 

osCommerce user since 2003! :thumbsup:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...