Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

hello,

using frozen 2341 and php 7.1.

I am trying to add a link to the navbar. i guess now you have to add a navbar module to admin>modules.navbar modules.

i took,  as a model,  the reviews navbar module, but  this is for an about us page. 

I created the three files below.

In the navbar the link shows up but as --MODULE_NAVBAR_ABOUTUS_PUBLIC_TEXT-- instead of just About Us.

I am missing something??? but just can not see what it is.

 

 

catalog\includes\modules\navbar_modules

<?php
/*
  $Id$

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

  Copyright (c) 2016 osCommerce

  Released under the GNU General Public License
*/

  class nb_aboutus {
    var $code = 'nb_aboutus';
    var $group = 'navbar_modules_home';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;    
    
    function __construct() {
      $this->title = MODULE_NAVBAR_ABOUTUS_TITLE;
      $this->description = MODULE_NAVBAR_ABOUTUS_DESCRIPTION;

      if ( defined('MODULE_NAVBAR_ABOUTUS_STATUS') ) {
        $this->sort_order = MODULE_NAVBAR_ABOUTUS_SORT_ORDER;
        $this->enabled = (MODULE_NAVBAR_ABOUTUS_STATUS == 'True');
        
        switch (MODULE_NAVBAR_ABOUTUS_CONTENT_PLACEMENT) {
          case 'Home':
          $this->group = 'navbar_modules_home';
          break;
          case 'Left':
          $this->group = 'navbar_modules_left';
          break;
          case 'Right':
          $this->group = 'navbar_modules_right';
          break;
        } 
      }
    }

    function getOutput() {
      global $oscTemplate;
      
      ob_start();
      require('includes/modules/navbar_modules/templates/aboutus.php');
      $data = ob_get_clean();

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

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

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

    function install() {
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable About Us Module', 'MODULE_NAVBAR_ABOUTUS_STATUS', 'True', 'Do you want to add the module to your Navbar?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_NAVBAR_ABOUTUS_CONTENT_PLACEMENT', 'Left', 'Should the module be loaded in the Left or Right or the Home area of the Navbar?', '6', '1', 'tep_cfg_select_option(array(\'Left\', \'Right\', \'Home\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_ABOUTUS_SORT_ORDER', '535', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    }

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

    function keys() {
      return array('MODULE_NAVBAR_ABOUTUS_STATUS', 'MODULE_NAVBAR_ABOUTUS_CONTENT_PLACEMENT', 'MODULE_NAVBAR_ABOUTUS_SORT_ORDER');
    }
  }

catalog\includes\modules\navbar_modules\templates

<?php
// in a template so that shopowners 
// don't have to change the main file!  

echo MODULE_NAVBAR_ABOUT_US_PUBLIC_TEXT;

catalog\includes\languages\english\modules\navbar_modules

<?php
/*
  $Id$

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

  Copyright (c) 2016 osCommerce

  Released under the GNU General Public License
*/

  define('MODULE_NAVBAR_ABOUTUS_TITLE', 'About Us'); 
  define('MODULE_NAVBAR_ABOUTUS_DESCRIPTION', 'Show About Us Link in Navbar.');
  
  define('MODULE_NAVBAR_ABOUTUS_PUBLIC_TEXT', '<li><a href="' . tep_href_link('aboutus.php') . '"><i class="fa fa-comment"></i><span class="hidden-sm"> About Us</span></a></li>');

 TY

Z
  

Link to comment
Share on other sites

Constant in text definition is:

MODULE_NAVBAR_ABOUTUS_PUBLIC_TEXT

Constant in template is:

MODULE_NAVBAR_ABOUT_US_PUBLIC_TEXT

Hope you see the difference.😉

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...