1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-18 12:21:45 +02:00

{MENU} shortcode fixed for BC and added new ability to call a Page/Menu directly.

eg. {MENU|feature-1} called from within a template would render the menu called 'feature-1' found in the Pages/Menus area of admin.
This commit is contained in:
Cameron
2013-03-08 20:27:12 -08:00
parent 3430c31048
commit 834dcf5f2b
4 changed files with 77 additions and 27 deletions

View File

@@ -168,7 +168,7 @@ class cpage_shortcodes extends e_shortcode
return '<a class="cpage" href="'.$url.'">'.$this->sc_cpagetitle().'</a>';
}
function sc_cpagebutton($parm)
function sc_cpagebutton($parm,$options)
{
$url = $this->sc_cpageurl();
@@ -176,13 +176,23 @@ class cpage_shortcodes extends e_shortcode
{
return $url;
}
return '<a class="cpage btn btn-small" href="'.$url.'">Read More..</a>';
parse_str($options,$options);
$text = vartrue($options['text'], "Read more..");
$size = vartrue($options['size'], "");
$inc = ($size) ? " btn-".$size : "";
return '<a class="cpage btn'.$inc.'" href="'.$url.'">'.$text.'</a>';
}
function sc_cmenutitle($parm='')
{
return e107::getParser()->toHTML($this->getParserVars()->menu_title, true, 'TITLE');
{
$tp = e107::getParser();
$title = $tp->glyph($this->page['menu_title']); // (preg_replace('/i_([\w]*)/',"<i class='i_$1'></i>",$this->page['menu_title']);
return $tp->toHTML($title, true, 'TITLE');
}
@@ -197,6 +207,11 @@ class cpage_shortcodes extends e_shortcode
{
// print_a($this);
$img = e107::getParser()->thumbUrl($this->page['menu_image']);
if($parm == 'url')
{
return $img;
}
return "<img src='".$img."' alt='' />";
}

View File

@@ -1,9 +1,33 @@
<?php
/* $Id$ */
function menu_shortcode($parm)
if(!defined('e107_INIT'))
{
return e107::getMenu()->renderArea($parm);
exit();
}
function menu_shortcode($parm, $mode='')
{
list($path,$echo) = explode(':', $parm);
if($mode) // New in v2.x. eg. {MENU|feature-1} Renders a menu called 'feature-1' as found in the e107_page table See admin Pages/Menus .
{
return e107::getMenu()->renderMenu($mode, false);
}
if(is_numeric($path)) // eg. {MENU=1} - renders area 1 as found in the e107_menu db table.
{
return e107::getMenu()->renderArea($parm);
}
else // eg. {MENU=contact} for e107_plugins/contact/contact_menu.php OR {MENU=contact/other} for e107_plugins/contact/other_menu.php
{
list($plugin,$menu) = explode("/",$path,2);
if($menu == '')
{
$menu = $plugin;
}
return e107::getMenu()->renderMenu($plugin,$menu."_menu");
}
}