1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

e_sitelink.php now supports html as well as link array. e_sitelink.php example added to Plugin Builder and _blank plugin.

Mega-Menus will be super-easy with this enhancement.
This commit is contained in:
Cameron 2016-05-07 09:07:38 -07:00
parent 5c3b486adc
commit 996b1f3285
5 changed files with 154 additions and 8 deletions

View File

@ -30,7 +30,7 @@ $NAVIGATION_TEMPLATE['main']['item_active'] = '
// Main Link which has a sub menu.
$NAVIGATION_TEMPLATE['main']['item_submenu'] = '
<li class="dropdown">
<li class="dropdown {LINK_IDENTIFIER}">
<a class="dropdown-toggle" role="button" data-toggle="dropdown" data-target="#" href="{LINK_URL}" title="{LINK_DESCRIPTION}">
{LINK_ICON}{LINK_NAME}
<span class="caret"></span>
@ -41,7 +41,7 @@ $NAVIGATION_TEMPLATE['main']['item_submenu'] = '
// Main Link which has a sub menu - active state.
$NAVIGATION_TEMPLATE['main']['item_submenu_active'] = '
<li class="dropdown active">
<li class="dropdown active {LINK_IDENTIFIER}">
<a class="dropdown-toggle" role="button" data-toggle="dropdown" data-target="#" href="{LINK_URL}">
{LINK_ICON}{LINK_NAME}
<span class="caret"></span>

View File

@ -2797,7 +2797,7 @@ class e_form
function name2id($name)
{
$name = strtolower($name);
return rtrim(str_replace(array('[]', '[', ']', '_', '/', ' ','.', '(', ')'), array('-', '-', '', '-', '-', '-', '-','',''), $name), '-');
return rtrim(str_replace(array('[]', '[', ']', '_', '/', ' ','.', '(', ')', '::'), array('-', '-', '', '-', '-', '-', '-','','','-'), $name), '-');
}
/**

View File

@ -1499,13 +1499,20 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; }
*/
public function compile(&$inArray, &$outArray, $pid = 0)
{
if(!is_array($inArray) || !is_array($outArray)){ return; }
if(!is_array($inArray) || !is_array($outArray)){ return null; }
$frm = e107::getForm();
foreach($inArray as $key => $val)
{
if($val['link_parent'] == $pid)
{
$val['link_sub'] = $this->isDynamic($val);
if(empty($val['link_identifier']) && !empty($val['link_function']))
{
$val['link_identifier'] = $frm->name2id($val['link_function']);
}
// prevent loop of death
if( $val['link_id'] != $pid) $this->compile($inArray, $val['link_sub'], $val['link_id']);
$outArray[] = $val;
@ -1829,13 +1836,23 @@ class navigation_shortcodes extends e_shortcode
*/
function sc_link_sub($parm='')
{
if(!varset($this->var['link_sub']))
if(empty($this->var['link_sub']))
{
return;
}
return false;
}
if(is_string($this->var['link_sub'])) // html override option.
{
e107::getDebug()->log($this->var);
return $this->var['link_sub'];
}
// Assume it's an array.
$text = e107::getParser()->parseTemplate(str_replace('{LINK_SUB}', '', $this->template['submenu_start']), true, $this);
foreach($this->var['link_sub'] as $val)
{
$active = (e107::getNav()->isActive($val, $this->activeSubFound, true)) ? "_active" : "";

View File

@ -0,0 +1,27 @@
/* e_sitelink */
/* this class name is auto-generated from the plugin name and function name e_sitelink */
.-blank-megamenu { position: static !important; }
.mega-dropdown-menu {
padding: 20px 15px 15px;
text-align: center;
width: 100%;
}
.nav-list { border-bottom: 0 solid #eee; }
.nav-list > li {
padding: 20px 15px 15px;
}
.nav-list > li:last-child { border-right: 0 solid #eee; }
.nav-list > li > a:hover { text-decoration: none; }
.nav-list > li > a > span {
display: block;
font-weight: bold;
text-transform: uppercase;
}

View File

@ -0,0 +1,102 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Sitelinks configuration module - gsitemap
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/_blank/e_sitelink.php,v $
* $Revision$
* $Date$
* $Author$
*
*/
if (!defined('e107_INIT')) { exit; }
/*if(!e107::isInstalled('gsitemap'))
{
return;
}*/
class _blank_sitelink // include plugin-folder in the name.
{
function config()
{
global $pref;
$links = array();
$links[] = array(
'name' => "Drop-Down Links",
'function' => "myCategories"
);
$links[] = array(
'name' => 'Drop-Down MegaMenu',
'function' => 'megaMenu'
);
return $links;
}
function megaMenu() // http://bootsnipp.com/snippets/33gmp
{
$text = '<div class="dropdown-menu mega-dropdown-menu">
<div class="container-fluid2">
<ul class="nav-list list-inline">
<li><a data-filter=".89" href="#"><img src="http://content.nike.com/content/dam/one-nike/globalAssets/menu_header_images/OneNike_Global_Nav_Icons_Running.png"><span>BRICS</span></a></li>
<li><a data-filter=".97" href="#"><img src="http://content.nike.com/content/dam/one-nike/globalAssets/menu_header_images/OneNike_Global_Nav_Icons_Basketball.png"><span>Latin America</span></a></li>
<li><a data-filter=".96" href="#"><img src="http://content.nike.com/content/dam/one-nike/globalAssets/menu_header_images/OneNike_Global_Nav_Icons_Football.png"><span>USA</span></a></li>
<li><a data-filter=".87" href="#"><img src="http://content.nike.com/content/dam/one-nike/globalAssets/menu_header_images/OneNike_Global_Nav_Icons_Soccer.png"><span>Middle East</span></a></li>
<li><a data-filter=".85" href="#"><img src="http://content.nike.com/content/dam/one-nike/globalAssets/menu_header_images/OneNike_Global_Nav_Icons_MensTraining.png"><span>Asia</span></a></li>
<li><a data-filter=".90" href="#"><img src="http://content.nike.com/content/dam/one-nike/globalAssets/menu_header_images/OneNike_Global_Nav_Icons_MensTraining.png"><span>Africa</span></a></li>
</ul>
</div>
</div> ';
return $text;
}
function myCategories()
{
$sql = e107::getDb();
$tp = e107::getParser();
$sublinks = array();
$sql->select("_blank_info","*","faq_info_id != '' ORDER BY faq_info_order");
while($row = $sql->fetch())
{
$sublinks[] = array(
'link_name' => $tp->toHtml($row['faq_info_title'],'','TITLE'),
'link_url' => e107::url('_blank', 'category', $row),
'link_description' => $row['faq_info_about'],
'link_button' => $row['faq_info_icon'],
'link_category' => '',
'link_order' => '',
'link_parent' => '',
'link_open' => '',
'link_class' => intval($row['faq_info_class'])
);
}
return $sublinks;
}
}