Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Navigation Bar Modularisation
This will consist of the Navbar Content Module, and a bunch of Sub Modules
- Loading branch information
Showing
5 changed files
with
92 additions
and
132 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
admin/includes/languages/english/modules/cfg_modules/cfgm_navbar_modules.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?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_CFG_MODULE_CONTENT_NAVBAR_TITLE', 'Navbar Modules'); |
25 changes: 25 additions & 0 deletions
25
admin/includes/modules/cfg_modules/cfgm_navbar_modules.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/* | ||
$Id$ | ||
osCommerce, Open Source E-Commerce Solutions | ||
http://www.oscommerce.com | ||
Copyright (c) 2016 osCommerce | ||
Released under the GNU General Public License | ||
*/ | ||
|
||
class cfgm_navbar_modules { | ||
var $code = 'navbar_modules'; | ||
var $directory; | ||
var $language_directory = DIR_FS_CATALOG_LANGUAGES; | ||
var $key = 'MODULE_CONTENT_NAVBAR_INSTALLED'; | ||
var $title; | ||
var $template_integration = false; | ||
|
||
function cfgm_navbar_modules() { | ||
$this->directory = DIR_FS_CATALOG_MODULES . 'navbar_modules/'; | ||
$this->title = MODULE_CFG_MODULE_CONTENT_NAVBAR_TITLE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 19 additions & 93 deletions
112
includes/modules/content/navigation/templates/navbar.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,25 @@ | ||
<nav class="navbar navbar-inverse navbar-no-corners navbar-no-margin" role="navigation"> | ||
<div class="<?php echo BOOTSTRAP_CONTAINER; ?>"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-navbar-collapse-core-nav"> | ||
<span class="sr-only"><?php echo HEADER_TOGGLE_NAV; ?></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
</div> | ||
<?php | ||
if ($oscTemplate->hasBlocks('navbar_modules_home')) { | ||
echo '<div class="navbar-header">' . PHP_EOL; | ||
echo $oscTemplate->getBlocks('navbar_modules_home'); | ||
echo '</div>' . PHP_EOL; | ||
} | ||
?> | ||
<div class="collapse navbar-collapse" id="bs-navbar-collapse-core-nav"> | ||
<ul class="nav navbar-nav"> | ||
<?php echo '<li><a class="store-brand" href="' . tep_href_link(FILENAME_DEFAULT) . '">' . HEADER_HOME . '</a></li>'; ?> | ||
<?php echo '<li><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . HEADER_WHATS_NEW . '</a></li>'; ?> | ||
<?php echo '<li><a href="' . tep_href_link(FILENAME_SPECIALS) . '">' . HEADER_SPECIALS . '</a></li>'; ?> | ||
<?php echo '<li><a href="' . tep_href_link(FILENAME_REVIEWS) . '">' . HEADER_REVIEWS . '</a></li>'; ?> | ||
</ul> | ||
<ul class="nav navbar-nav navbar-right"> | ||
<?php | ||
if (substr(basename($PHP_SELF), 0, 8) != 'checkout') { | ||
?> | ||
<li class="dropdown"> | ||
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php echo HEADER_SITE_SETTINGS; ?></a> | ||
<ul class="dropdown-menu"> | ||
<li class="text-center text-muted bg-primary"><?php echo sprintf(USER_LOCALIZATION, ucwords($language), $currency); ?></li> | ||
<?php | ||
// languages | ||
if (!isset($lng) || (isset($lng) && !is_object($lng))) { | ||
include(DIR_WS_CLASSES . 'language.php'); | ||
$lng = new language; | ||
} | ||
if (count($lng->catalog_languages) > 1) { | ||
echo '<li class="divider"></li>'; | ||
reset($lng->catalog_languages); | ||
while (list($key, $value) = each($lng->catalog_languages)) { | ||
echo '<li><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_LANGUAGES . $value['directory'] . '/images/' . $value['image'], $value['name'], null, null, null, false) . ' ' . $value['name'] . '</a></li>'; | ||
} | ||
} | ||
// currencies | ||
if (isset($currencies) && is_object($currencies) && (count($currencies->currencies) > 1)) { | ||
echo '<li class="divider"></li>'; | ||
reset($currencies->currencies); | ||
$currencies_array = array(); | ||
while (list($key, $value) = each($currencies->currencies)) { | ||
$currencies_array[] = array('id' => $key, 'text' => $value['title']); | ||
echo '<li><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'currency=' . $key, $request_type) . '">' . $value['title'] . '</a></li>'; | ||
} | ||
} | ||
?> | ||
</ul> | ||
</li> | ||
<?php | ||
} | ||
?> | ||
<li class="dropdown"> | ||
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php echo (tep_session_is_registered('customer_id')) ? sprintf(HEADER_ACCOUNT_LOGGED_IN, $customer_first_name) : HEADER_ACCOUNT_LOGGED_OUT; ?></a> | ||
<ul class="dropdown-menu"> | ||
<?php | ||
if (tep_session_is_registered('customer_id')) { | ||
echo '<li><a href="' . tep_href_link(FILENAME_LOGOFF, '', 'SSL') . '">' . HEADER_ACCOUNT_LOGOFF . '</a>'; | ||
} | ||
else { | ||
echo '<li><a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '">' . HEADER_ACCOUNT_LOGIN . '</a>'; | ||
echo '<li><a href="' . tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL') . '">' . HEADER_ACCOUNT_REGISTER . '</a>'; | ||
} | ||
?> | ||
<li class="divider"></li> | ||
<li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . HEADER_ACCOUNT . '</a>'; ?></li> | ||
<li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL') . '">' . HEADER_ACCOUNT_HISTORY . '</a>'; ?></li> | ||
<li><?php echo '<a href="' . tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL') . '">' . HEADER_ACCOUNT_ADDRESS_BOOK . '</a>'; ?></li> | ||
<li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL') . '">' . HEADER_ACCOUNT_PASSWORD . '</a>'; ?></li> | ||
</ul> | ||
</li> | ||
<?php | ||
if ($cart->count_contents() > 0) { | ||
?> | ||
<li class="dropdown"> | ||
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php echo sprintf(HEADER_CART_CONTENTS, $cart->count_contents()); ?></a> | ||
<ul class="dropdown-menu"> | ||
<li><?php echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . sprintf(HEADER_CART_HAS_CONTENTS, $cart->count_contents(), $currencies->format($cart->show_total())) . '</a>'; ?></li> | ||
<?php | ||
if ($cart->count_contents() > 0) { | ||
echo '<li class="divider"></li>'; | ||
echo '<li><a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . HEADER_CART_VIEW_CART . '</a></li>'; | ||
} | ||
?> | ||
</ul> | ||
</li> | ||
<?php | ||
echo '<li><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . HEADER_CART_CHECKOUT . '</a></li>'; | ||
} | ||
else { | ||
echo '<li class="nav navbar-text">' . HEADER_CART_NO_CONTENTS . '</li>'; | ||
} | ||
?> | ||
</ul> | ||
<?php | ||
if ($oscTemplate->hasBlocks('navbar_modules_left')) { | ||
echo '<ul class="nav navbar-nav">' . PHP_EOL; | ||
echo $oscTemplate->getBlocks('navbar_modules_left'); | ||
echo '</ul>' . PHP_EOL; | ||
} | ||
if ($oscTemplate->hasBlocks('navbar_modules_right')) { | ||
echo '<ul class="nav navbar-nav navbar-right">' . PHP_EOL; | ||
echo $oscTemplate->getBlocks('navbar_modules_right'); | ||
echo '</ul>' . PHP_EOL; | ||
} | ||
?> | ||
</div> | ||
</div> | ||
</nav> |
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is the start of sub modularisation for the Navigation Bar.
This will allow easy "editing" of the Navigation Bar, but the flip-side of that is it makes it much harder to add in new items (as they have to be a module rather than a simple change to the main template file).
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the kymation addon "Modular Navigation Bar (Bootstrap)" and my opinion was that I prefer the simplest way: because that flip-side. But maybe because I don't need it: maybe other stores need modular control. Harder from easy coding but coherent with modularized design store.
Welcome anyway :)
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know there was an addon for it 🔮
Would have saved me some time and effort.
Off to test it now...
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'm glad I mentioned that! :D
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 @katapofatico thanks for the heads-up
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, tested kymations addon - and it does exactly what I had plans for in this branch.
Allows the shopowner to turn off/on navbar items, swap them around and so on.
My idea is pretty much the same.
I believe it can be done a little bit cleaner than the Addon, so I will carry on and see where it goes.
Thanks for the heads-up @katapofatico - appreciated much.
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm conflicted. I'd like to keep compatiblility for the modules, as keeping two differnt versions of each one would be a pain. (There are already four additional modules for my addon that are not in the stock collection.)
On the other hand, I'd really like to see how you would simplify this. I could stand to learn how to do that.
And if you'd like to save some more time, the front page modules have also been done and are available as an addon.
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kymation the basis of my thought is to use a similar approach as is done at the "social bookmarks" module. This has an extra page in admin for add/edit/delete the submodules (which make up the main module). It's basically the same as you have done...just a little bit cleaner. Keep an eye on this Branch - as you have already done some work in this area I woud be grateful for any pointers if I run into problems. Thanks.
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's done so far, bear in mind untested !
Addition of new cfgm module to add the link into the modules sidebox in admin.
Update the main navbar content module to pull in submodules.
Update the main navbar template file to pull in getBlocks
which leaves:
make a bunch of submodules that plug into the oscTemplate->getblocks
I'll make 1 or 2 today/tomorrow...for testing...
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what I did: I copied the approach used in the Social Bookmarks module. No cfgm module needed. Compare the structure and you'll see what I did.
bm_product_social_bookmarks.php => cm_modular_navbar.php
social_bookmarks/{any module file} => content/navbar/{any module file}
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've committed a couple of sub modules.
Feel free to test - any feedback would be appreciated.
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, Github is being mean to me. Where are the submodules?
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
40db14b
1d22fe2
should do it
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
af86f42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All commits now completed, this should take the Navbar fully modular; https://github.com/gburton/Responsive-osCommerce/commits/ModNav