Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Creating New Navbar above Existing Navbar


rebelsheep

Recommended Posts

Hi, I'm looking to create my own menubar with drop down menus that is above the existing navbar.

The reason for doing this is we have a lot of top level categories / menu items - so using the full width of the screen (on laptop / desktop) would be useful.

So we would get more space to play with if we place our own menubar above the existing navbar, which currently holds the title of our site + Home + Currency Selector + Basket.

What files do I need to edit to insert my own code in the place I would like?

As a crude hack, and because I don't fully know OSCommerce yet.... I tried editing template_top.php in the includes folder, and stuck <p>hello</p> just below body, hoping that it would be this easy and I would see 'hello' on my website at the top of the page above the navbar. Needless to say, this didn't work.

Current test site:

http://notebookrepair.rocks/index.php

The type of menu I am trying to achieve is at the top of this site:

https://shop.notebookrepair.co.uk/

 

Thank you.

 

Link to comment
Share on other sites

You can just put the example navbar there where you are trying to echo Hello, and build your navbar around that. here is the code:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Dropdown
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="#">Action</a>
          <a class="dropdown-item" href="#">Another action</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="#">Something else here</a>
        </div>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>

if you want space between the 2 navbars then replace the first line of code with:

<nav class="navbar navbar-expand-lg navbar-light bg-light mb-3">

 

Link to comment
Share on other sites

Thank you HotClutch - that's excellent.

The problem was with my FTP client - or rather me. Somehow I had set it to not overwrite existing files!!

This has been killing me. Wasting hours banging head against wall with simple code that I KNOW MUST WORK.

Doh!

I now have a menubar that does what I would like - thank you so much.

Link to comment
Share on other sites

11 minutes ago, rebelsheep said:

Or should I be inserting my custom code in to the website by creating my own modules?

Yes just make a new module header  or nav and then you can select which order it shows on the site. Just pick an existing one rename it and add your code.

 

Link to comment
Share on other sites

So i just copy an existing module in includes/modules.

So for example I copy nb_currencies.php

And then when I edit it - it needs all the functions:

    function __construct()

   function getOutput()

   function isEnabled()

   function check()

   function install()

   function remove()

   function keys()

?

And in which of the functions would I put the custom code?

Thank you for your help, still learning.

Link to comment
Share on other sites

And I put my custom code in execute()

global $oscTemplate;

$mymenu = "<nav class='navbar navbar-expand-lg navbar-light bg-light'>";

$mymenu = $mymenu . " <div class='collapse navbar-collapse' id='navbarSupportedContent'>";
$mymenu = $mymenu . " <ul class='navbar-nav mr-auto'>";
$mymenu = $mymenu . "<li class='nav-item dropdown nr-nav'>";
$mymenu = $mymenu . "<a class='nav-link dropdown-toggle' href='#' id='navbarDropdown' role='button' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>";
$mymenu = $mymenu . "Autocab";
$mymenu = $mymenu . "</a>";
$mymenu = $mymenu . "<div class='dropdown-menu' aria-labelledby='navbarDropdown'>";
$mymenu = $mymenu . "<a class='dropdown-item nr-nav' href='#'>Autocab PDAs</a>";
$mymenu = $mymenu . "<a class='dropdown-item nr-nav' href='#'>Autocab Phones</a>";
$mymenu = $mymenu . "<a class='dropdown-item nr-nav' href='#'>Autocab Radios</a>";
$mymenu = $mymenu . "<a class='dropdown-item nr-nav' href='#'>Autocab Mobile Data Terminals</a>";
$mymenu = $mymenu . "<a class='dropdown-item nr-nav' href='#'>Autocab Tablets</a>";
$mymenu = $mymenu . "<a class='dropdown-item nr-nav' href='#'>Autocab Accessories</a>";          
$mymenu = $mymenu . "</div>";
$mymenu = $mymenu . "</li></ul></div></nav>";

$oscTemplate->addContent($mymneu, $this->group);

 

Link to comment
Share on other sites

It worked when I changed the code in execute - and without further editing it was using the parameters from BREADCRUMB (because this was the file I copied).

So now tried to give it it's own parameters - just enabled/disabled, SortOrder.

But in Admin these values remain blank. What else do I need to do so values/parameters for this module are stored in the database?

Here is the code:

  class cm_header_nbrmenu {
    var $code;
    var $group;
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function __construct() {
      $this->code = get_class($this);
      $this->group = basename(dirname(__FILE__));

      $this->title = "Notebook Repair Menu";
      $this->description = "Notebook Repair Custom";

      if ( defined('MODULE_CONTENT_HEADER_NBRMENU_STATUS') ) {
        $this->sort_order = MODULE_CONTENT_HEADER_NBRMENU_SORT_ORDER;
        $this->enabled = (MODULE_CONTENT_HEADER_NBRMENU_STATUS == 'True');
      }
    }

    function execute() {
      global $oscTemplate;
      
      $mymenu = "<nav class='navbar navbar-expand-lg navbar-light bg-light'>";
$mymenu .= "<div class='collapse navbar-collapse' id='navbarSupportedContent'>";
$mymenu .= "<ul class='navbar-nav mr-auto'>";
$mymenu .= "<li class='nav-item dropdown nr-nav'>";
$mymenu .= "<a class='nav-link dropdown-toggle' href='#' id='navbarDropdown' role='button' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>";
$mymenu .= "Autocab";
$mymenu .= "</a>";
$mymenu .= "<div class='dropdown-menu' aria-labelledby='navbarDropdown'>";
$mymenu .= "<a class='dropdown-item nr-nav' href='#'>Autocab PDAs</a>";
$mymenu .= "<a class='dropdown-item nr-nav' href='#'>Autocab Phones</a>";
$mymenu .= "<a class='dropdown-item nr-nav' href='#'>Autocab Radios</a>";
$mymenu .= "<a class='dropdown-item nr-nav' href='#'>Autocab Mobile Data Terminals</a>";
$mymenu .= "<a class='dropdown-item nr-nav' href='#'>Autocab Tablets</a>";
$mymenu .= "<a class='dropdown-item nr-nav' href='#'>Autocab Accessories</a>";          
$mymenu .= "</div>";
$mymenu .= "</li></ul></div></nav>";

      $oscTemplate->addContent($mymenu, $this->group);
    }

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

    function check() {
      return defined('MODULE_CONTENT_HEADER_NBRMENU_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 Header NBRMenu Module', 'MODULE_CONTENT_HEADER_NBRMENU_STATUS', 'True', 'Do you want to enable the NBRMenu content module?', '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, date_added) values ('Sort Order', 'MODULE_CONTENT_HEADER_NBRMENU_SORT_ORDER', '0', '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_CONTENT_HEADER_NBRMENU_STATUS', 'MODULE_CONTENT_HEADER_NBRMENU_SORT_ORDER');
    }
  }

 

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...