Skip to content

Commit

Permalink
Navbar: Modular Home Link
Browse files Browse the repository at this point in the history
  • Loading branch information
gburton committed Feb 22, 2016
1 parent af86f42 commit 1d22fe2
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
17 changes: 17 additions & 0 deletions includes/languages/english/modules/navbar_modules/nb_home.php
@@ -0,0 +1,17 @@
<?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_HOME_TITLE', 'Home');
define('MODULE_NAVBAR_HOME_DESCRIPTION', 'Show Home Link in Navbar. <div class="secWarning">If you wish to have a Home button permanently displayed (even when the rest of the Menu is collapsed, eg in XS viewport) you could use the Brand module instead.</div>');

define('MODULE_NAVBAR_HOME_PUBLIC_TEXT', '<li><a href="' . tep_href_link('index.php') . '"><i class="fa fa-home"></i><span class="hidden-sm"> Home</span></a></li>');

75 changes: 75 additions & 0 deletions includes/modules/navbar_modules/nb_home.php
@@ -0,0 +1,75 @@
<?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_home {
var $code = 'nb_home';
var $group = 'navbar_modules_home';
var $title;
var $description;
var $sort_order;
var $enabled = false;

function nb_home() {
$this->title = MODULE_NAVBAR_HOME_TITLE;
$this->description = MODULE_NAVBAR_HOME_DESCRIPTION;

if ( defined('MODULE_NAVBAR_HOME_STATUS') ) {
$this->sort_order = MODULE_NAVBAR_HOME_SORT_ORDER;
$this->enabled = (MODULE_NAVBAR_HOME_STATUS == 'True');

switch (MODULE_NAVBAR_HOME_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(DIR_WS_MODULES . 'navbar_modules/templates/home.php');
$data = ob_get_clean();

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

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

function check() {
return defined('MODULE_NAVBAR_HOME_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 Home Module', 'MODULE_NAVBAR_HOME_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_HOME_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_HOME_SORT_ORDER', '520', '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_HOME_STATUS', 'MODULE_NAVBAR_HOME_CONTENT_PLACEMENT', 'MODULE_NAVBAR_HOME_SORT_ORDER');
}
}

5 changes: 5 additions & 0 deletions includes/modules/navbar_modules/templates/home.php
@@ -0,0 +1,5 @@
<?php
// in a template so that shopowners
// don't have to change the main file!

echo MODULE_NAVBAR_HOME_PUBLIC_TEXT;

1 comment on commit 1d22fe2

@gburton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modular Home Link

If this one works, more to follow...

Please sign in to comment.