Skip to content

Commit

Permalink
Added setShowHasSubClass() and setHasSubClass()
Browse files Browse the repository at this point in the history
  • Loading branch information
RexDude committed Nov 18, 2015
1 parent f496427 commit 1baf72f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ Navigation Factory - Changelog
* Geändert: Methode `setLinkFromUserFunc()` in `setCustomLink()` umbenannt
* Geändert: Es gab umfangreiche Änderungen an der Breadcrumb Navigation. Bitte die Codebeispiele studieren
* Neu: Methode `setListClass()` zur Klasse `rex_lang_nav` hinzugefügt, thx@darwin
* Neu: Methode `setShowHasSubClass()` zur Klasse `rex_lang_nav` hinzugefügt, zeigt automatisch eine 'has-sub' Klasse für die Ul an
* Neu: Methode `setHasSubClass()` zur Klasse `rex_lang_nav` hinzugefügt, zum ändern des Klassenmames. default ist 'has-sub'

31 changes: 26 additions & 5 deletions classes/class.rex_nav.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class rex_nav {
protected $hideIds;
protected $listItemIdFromCategoryId;
protected $listItemClassFromCategoryId;
protected $showHasSubClass;
protected $hasSubClass;

// old vars from rex_navigation
var $path = array();
Expand All @@ -41,6 +43,8 @@ public function __construct() {
$this->hideIds = array();
$this->listItemIdFromCategoryId = array();
$this->listItemClassFromCategoryId = array();
$this->showHasSubClass = false;
$this->hasSubClass = 'has-sub';
}

public function getNavigation() {
Expand Down Expand Up @@ -123,30 +127,47 @@ public function setListItemClassFromCategoryId($listItemClassFromCategoryId) {
$this->listItemClassFromCategoryId = $listItemClassFromCategoryId;
}

public function setShowHasSubClass($showHasSubClass) {
$this->showHasSubClass = $showHasSubClass;
}

public function setHasSubClass($hasSubClass) {
$this->hasSubClass = $hasSubClass;
}

protected function _getNavigation($categoryId) {
global $REX;

static $depth = 0;

$return = '';
$listIdAttribute = '';
$listClassAttribute = '';
$listClasses = '';

if ($categoryId < 0) {
return '';
} elseif ($categoryId < 1) {
$cats = OOCategory::getRootCategories($this->ignoreOfflines);
} else {
$cats = OOCategory::getChildrenById($categoryId, $this->ignoreOfflines);
}

$return = '';
$listIdAttribute = '';
$listClassAttribute = '';
if ($this->showHasSubClass) {
$listClasses .= ' ' . $this->hasSubClass;
}
}

if (count($cats) > 0) {
if (isset($this->listId[$depth])) {
$listIdAttribute = ' id="' . $this->listId[$depth] . '"';
}

if (isset($this->listClass[$depth])) {
$listClassAttribute = ' class="' . $this->listClass[$depth] . '"';
$listClasses .= ' ' . $this->listClass[$depth];
}

if ($listClasses != '') {
$listClassAttribute = ' class="' . trim($listClasses) . '"';
}

$return .= '<ul' . $listIdAttribute . $listClassAttribute . '>';
Expand Down
2 changes: 2 additions & 0 deletions docs/rex_nav.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ $nav->setHideWebsiteStartArticle(true); // startartikel der website wird ausgebl
$nav->setHideIds(array(42, 108)); // kategorien mit ids 42 und 108 werden ausgeblendet
$nav->setSelectedClass('current'); // li klasse für selektierte menüpunkte: 'current'
$nav->setActiveClass('current active'); // li klasse für gerade aktiven menüpunkt: 'current active'
$nav->setShowHasSubClass(true); // zeigt 'has-sub' klasse für die ul an
$nav->setHasSubClass('has-sub'); // klassenname der 'has-sub' klasse
$nav->setListId('nav', 1); // erste ul id: 'nav'
$nav->setListClass('sf-menu', 1); // erste ul klasse 'sf-menu'
$nav->setListItemClass('list-item'); // li klasse 'list-item'
Expand Down

0 comments on commit 1baf72f

Please sign in to comment.