Skip to content

Commit 6569184

Browse files
committed
Added updated files
1 parent 12405d6 commit 6569184

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ The folders in this repo are as follows:
2121
2. Copy the contents of `libraries` and `models` into their respective folders in your `application` directory.
2222
3. Import the library whenever you need to output navigation; typically your header partial view using:
2323
```php
24-
$this->load->library('ci-navigation');
24+
$this->load->library('navigation');
2525
```
2626
You can also autoload it if you need navigation on every page.

libraries/Navigation.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function outputItem($item) {
138138
/**
139139
* Outputs the markup for a single item.
140140
* @param item : query row for a single nav item.
141-
* @returns output : string composed of HTML to be rendered
141+
* @return output : string composed of HTML to be rendered
142142
*/
143143

144144
$output = '';
@@ -186,20 +186,32 @@ function renderDropdown($subItems) {
186186
/**
187187
* Takes subitems and returns markup.
188188
* @param subItems : Query result containing nav items
189-
* @returns output : string composed of HTML to be rendered
189+
* @return output : string composed of HTML to be rendered
190190
*/
191191

192192
$output = $this->_dropdown_open;
193193

194194
foreach ($subItems->result() as $item) {
195+
$subOutput = $this->_item_open;
196+
$classes = '';
195197

196198
// Check if current page and open item
197199
if ($this->isCurrentPage($item->ItemLink)) {
198-
$output .= $this->_item_open_active;
199-
} else {
200-
$output .= $this->_item_open;
200+
$classes .= $this->_item_open_active_class . ' ';
201201
}
202202

203+
if (!is_null($subItems) && count($subItems->result()) > 0){
204+
// See if we have dropdown
205+
$classes .= $this->_item_open_dropdown_class . ' ';
206+
}
207+
208+
if(!strcmp($classes,'') == 0) {
209+
// If classes to add them append to open tag
210+
$subOutput = str_replace('>',' class="' . $classes . '">',$subOutput);
211+
}
212+
213+
$output .= $subOutput;
214+
203215
// Output link
204216
$output .= $this->bindAnchor($item->ItemLink, $item->ItemHumanName);
205217

@@ -217,7 +229,7 @@ public function generateNav_fromName($menu_name)
217229
/**
218230
* Resolves a menu name to ID then returns the menu output.
219231
* @param menu_name : string identifier of the menu as in CI-Nav-Menus
220-
* @returns output : string composed of HTML to be rendered.
232+
* @return output : string composed of HTML to be rendered.
221233
*/
222234
$menu_id = $this->CI->nav->getMenuID($menu_name);
223235
return $this->generateNav_fromID($menu_id);
@@ -228,7 +240,7 @@ public function generateNav_fromID($menu_id) {
228240
* Generates output for menu from a menu ID as specified in
229241
* CI-Nav-Menus.
230242
* @param menu_id : int ID of the menu to be generate
231-
* @returns output : string composed of HTML to be rendered.
243+
* @return output : string composed of HTML to be rendered.
232244
*/
233245

234246
// Open Container
@@ -253,7 +265,7 @@ public function generateNav_fromID($menu_id) {
253265
public function generateRoleBasedNav() {
254266
/**
255267
* Outputs navigation selectively based on user authentication
256-
* @returns HTML markup for navigation
268+
* @return HTML markup for navigation
257269
*/
258270

259271
if (!$this->CI->ion_auth->logged_in()){

models/nav_model.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getMenuID($menu_name) {
2121
/**
2222
* Returns the id from associated menu handle
2323
* @param $menu_name : string name associated to menu defined in CI-Nav-Menus
24-
* @returns int menu ID otherwise -1;
24+
* @return int menu ID otherwise -1;
2525
*/
2626
if (isset($menu_name) && ctype_alnum ($menu_name)) {
2727
$query = $this->db->query('SELECT `MenuID` FROM `CI-Nav-Menus` WHERE `MenuName` = ?',array($menu_name));
@@ -37,7 +37,7 @@ public function getTopLevelNav_byName($menu_name) {
3737
* Returns the top level of a menu
3838
* @param $menu_name : String handle of menu e.g. 'public'
3939
* as defined in CI-Nav-Menus
40-
* @returns : Query with result, if invalid NULL
40+
* @return : Query with result, if invalid NULL
4141
*/
4242

4343
// Check $nav_name is not null
@@ -55,7 +55,7 @@ public function getTopLevelNav_byID($menu_ID) {
5555
/**
5656
* Returns the top level of a menu
5757
* @param $menu_ID : int ID of menu as defined in CI-Nav-Menus
58-
* @returns : Query with result
58+
* @return : Query with result
5959
*/
6060

6161
if (isset($menu_ID) && $menu_ID != -1 && ctype_digit($menu_ID)) {
@@ -78,7 +78,7 @@ public function getSubItems($item_ID) {
7878
* refs ItemID in CI-Nav-Items
7979
* @param $item_ID : int ID of menu item as defined in
8080
* CI-Nav-Items
81-
* @returns : Query with result of MenuItems
81+
* @return : Query with result of MenuItems
8282
*/
8383

8484
if (isset($item_ID) && ctype_digit($item_ID)) {

0 commit comments

Comments
 (0)