From 056cb08fa80e709886cd8b784b6f99bc1f9419f8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 1 Nov 2017 12:36:32 -0700 Subject: [PATCH] Additional {NAVIGATION} shortcode parms. eg. {NAVIGATION: type=main&layout=footer&flat=1&noempty=1} will flatten sublinks and remove links with no URL or '#'. Dynamic sublinks (functions) currently not supported. --- e107_core/shortcodes/single/navigation.php | 3 +-- e107_handlers/sitelinks_class.php | 27 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/e107_core/shortcodes/single/navigation.php b/e107_core/shortcodes/single/navigation.php index fe6ac41df..e677831da 100644 --- a/e107_core/shortcodes/single/navigation.php +++ b/e107_core/shortcodes/single/navigation.php @@ -44,8 +44,7 @@ $nav = e107::getNav(); $template = e107::getCoreTemplate('navigation', $tmpl); - $data = $nav->initData($category); -// $data = $nav->collection($category); + $data = $nav->initData($category,$parm); return $nav->render($data, $template); diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 8b1818a0d..9f0181834 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -1647,18 +1647,41 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } * --------------- CODE-EFFICIENT APPROACH ------------------------- * FIXME syscache */ - public function initData($cat=1) + public function initData($cat=1, $opt=array()) { $sql = e107::getDb('sqlSiteLinks'); - $ins = ($cat > 0) ? "link_category = ".intval($cat)." AND " : ""; + + $ins = ($cat > 0) ? " link_category = ".intval($cat)." AND " : ""; + $query = "SELECT * FROM #links WHERE ".$ins." ((link_class >= 0 AND link_class IN (".USERCLASS_LIST.")) OR (link_class < 0 AND link_class NOT IN (".USERCLASS_LIST.")) ) ORDER BY link_order,link_parent ASC"; $outArray = array(); $data = $sql->retrieve($query,true); + if(!empty($opt['flat'])) + { + $newArr = array(); + foreach($data as $row) + { + //$tmp = $this->isDynamic($row); //FIXME TODO Flatten dynamic links and add to $newArr + + if(!empty($opt['noempty']) && (empty($row['link_url']) || $row['link_url'] === '#')) + { + continue; + } + + $newArr[] = $row; + + } + + return $newArr; + } + $ret = $this->compile($data, $outArray); + + return $ret; }