1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 04:10:38 +02:00

Menu Template fixes and enhancements. Related News now has a template.

This commit is contained in:
Cameron
2016-03-10 17:32:36 -08:00
parent 51d59f83d9
commit d30135e026
7 changed files with 66 additions and 27 deletions

View File

@@ -879,8 +879,10 @@ class news_shortcodes extends e_shortcode
{ {
$array['types'] = 'news,page'; $array['types'] = 'news,page';
} }
return e107::getForm()->renderRelated($array, $this->news_item['news_meta_keywords'], array('news'=>$this->news_item['news_id'])); $template = e107::getTemplate('news', 'news', 'related');
return e107::getForm()->renderRelated($array, $this->news_item['news_meta_keywords'], array('news'=>$this->news_item['news_id']),$template);
} }

View File

@@ -1,23 +1,26 @@
<?php <?php
if (!defined('e107_INIT')) { exit; }
#### Panel Template - Used by menu_class.php for Custom Menu Content.
#### Additional control over image thumbnailing is possible via SETIMAGE e.g. {SETIMAGE: w=200&h=150&crop=1}
#### Panel Template - Used by menu_class.php for Custom Menu Content. $MENU_TEMPLATE['default']['start'] = '<div class="cpage-menu {CMENUNAME}">';
$MENU_TEMPLATE['default']['start'] = '';
$MENU_TEMPLATE['default']['body'] = '{CMENUBODY}'; $MENU_TEMPLATE['default']['body'] = '{CMENUBODY}';
$MENU_TEMPLATE['default']['end'] = ''; $MENU_TEMPLATE['default']['end'] = '</div>';
$MENU_TEMPLATE['button']['start'] = '<div class="cpage-menu">'; $MENU_TEMPLATE['button']['start'] = '<div class="cpage-menu {CMENUNAME}">';
$MENU_TEMPLATE['button']['body'] = '<div>{CMENUBODY}</div>{CPAGEBUTTON}'; $MENU_TEMPLATE['button']['body'] = '<div>{CMENUBODY}</div>{CPAGEBUTTON}';
$MENU_TEMPLATE['button']['end'] = '</div>'; $MENU_TEMPLATE['button']['end'] = '</div>';
### Additional control over image thumbnailing is possible via SETIMAGE e.g. {SETIMAGE: w=200&h=150&crop=1} $MENU_TEMPLATE['buttom-image']['start'] = '<div class="cpage-menu {CMENUNAME}">';
$MENU_TEMPLATE['buttom-image']['start'] = '<div class="cpage-menu">';
$MENU_TEMPLATE['buttom-image']['body'] = '<div>{CMENUIMAGE}</div>{CPAGEBUTTON}'; $MENU_TEMPLATE['buttom-image']['body'] = '<div>{CMENUIMAGE}</div>{CPAGEBUTTON}';
$MENU_TEMPLATE['buttom-image']['end'] = '</div>'; $MENU_TEMPLATE['buttom-image']['end'] = '</div>';
$MENU_TEMPLATE['image-only']['start'] = ''; $MENU_TEMPLATE['image-only']['start'] = '<div class="cpage-menu {CMENUNAME}">';
$MENU_TEMPLATE['image-only']['body'] = '{CMENUIMAGE}'; $MENU_TEMPLATE['image-only']['body'] = '{CMENUIMAGE}';
$MENU_TEMPLATE['image-only']['end'] = ''; $MENU_TEMPLATE['image-only']['end'] = '</div>';
$MENU_TEMPLATE['image-text-button']['start'] = '<div class="cpage-menu {CMENUNAME}">';
$MENU_TEMPLATE['image-text-button']['body'] = '{CMENUIMAGE}{CMENUBODY}{CPAGEBUTTON}';
$MENU_TEMPLATE['image-text-button']['end'] = '</div>';
?> ?>

View File

@@ -2876,7 +2876,7 @@ class e_form
* @param string $tags : comma separated list of keywords to return related items of. * @param string $tags : comma separated list of keywords to return related items of.
* @param array $curVal. eg. array('page'=> current-page-id-value); * @param array $curVal. eg. array('page'=> current-page-id-value);
*/ */
function renderRelated($parm,$tags, $curVal) //XXX TODO Cache! function renderRelated($parm,$tags, $curVal, $template=null) //XXX TODO Cache!
{ {
if(empty($tags)) if(empty($tags))
@@ -2895,6 +2895,19 @@ class e_form
{ {
$parm['types'] = 'news'; $parm['types'] = 'news';
} }
if(empty($template))
{
$TEMPLATE['start'] = "<hr><h4>".defset('LAN_RELATED', 'Related')."</h4><ul class='e-related'>";
$TEMPLATE['item'] = "<li><a href='{RELATED_URL}'>{RELATED_TITLE}</a></li>";
$TEMPLATE['end'] = "</ul>";
}
else
{
$TEMPLATE = $template;
}
$tp = e107::getParser(); $tp = e107::getParser();
@@ -2902,7 +2915,8 @@ class e_form
$types = explode(',',$parm['types']); $types = explode(',',$parm['types']);
$list = array(); $list = array();
$head = $tp->parseTemplate($TEMPLATE['start'],true);
foreach($types as $plug) foreach($types as $plug)
{ {
@@ -2919,15 +2933,25 @@ class e_form
{ {
foreach($tmp as $val) foreach($tmp as $val)
{ {
$list[] = "<li><a href='".$tp->replaceConstants($val['url'],'full')."'>".$val['title']."</a></li>";
$row = array(
'RELATED_URL' => $tp->replaceConstants($val['url'],'full'),
'RELATED_TITLE' => $val['title'],
'RELATED_IMAGE' => $tp->toImage($val['image']),
'RELATED_SUMMARY' => $tp->toHtml($val['summary'],true,'BODY')
);
$list[] = $tp->simpleParse($TEMPLATE['item'], $row);
} }
} }
} }
if(count($list)) if(count($list))
{ {
return "<div class='e-related clearfix hidden-print'><hr><h4>".defset('LAN_RELATED', 'Related')."</h4><ul class='e-related'>".implode("\n",$list)."</ul></div>"; //XXX Tablerender? return "<div class='e-related clearfix hidden-print'>".$head.implode("\n",$list).$tp->parseTemplate($TEMPLATE['end'], true)."</div>";
// return "<div class='e-related clearfix hidden-print'><hr><h4>".defset('LAN_RELATED', 'Related')."</h4><ul class='e-related'>".implode("\n",$list)."</div>"; //XXX Tablerender?
} }
} }

View File

@@ -478,11 +478,11 @@ class e_menu
$page_shortcodes = e107::getScBatch('page',null,'cpage'); $page_shortcodes = e107::getScBatch('page',null,'cpage');
$page_shortcodes->setVars($page); $page_shortcodes->setVars($page);
$head = $tp->parseTemplate($template['start'], true); $head = $tp->parseTemplate($template['start'], true, $page_shortcodes);
$foot = $tp->parseTemplate($template['end'], true); $foot = $tp->parseTemplate($template['end'], true, $page_shortcodes);
// print_a($template['body']); // print_a($template['body']);
$text = $head.$tp->parseTemplate($template['body'], true, $page_shortcodes).$template['end']; $text = $head.$tp->parseTemplate($template['body'], true, $page_shortcodes).$foot;
// echo "TEMPLATE= ($mpath)".$page['menu_template']; // echo "TEMPLATE= ($mpath)".$page['menu_template'];

View File

@@ -32,11 +32,13 @@ class news_related // include plugin-folder in the name.
{ {
while($row = $sql->fetch()) while($row = $sql->fetch())
{ {
$thumbs = !empty($row['news_thumbnail']) ? explode(",",$row['news_thumbnail']) : array();
$items[] = array( $items[] = array(
'title' => varset($row['news_title']), 'title' => varset($row['news_title']),
'url' => e107::getUrl()->create('news/view/item',$row), // '{e_BASE}news.php?extend.'.$row['news_id'], 'url' => e107::getUrl()->create('news/view/item',$row), // '{e_BASE}news.php?extend.'.$row['news_id'],
'body' => varset($row['news_summary']), 'summary' => varset($row['news_summary']),
'image' => varset($row['news_image']) 'image' => $thumbs[0]
); );
} }

View File

@@ -196,4 +196,12 @@ $NEWS_TEMPLATE['category']['item'] = '
</td></tr> </td></tr>
</table> </table>
</div> </div>
'; ';
### Related 'start' - Options: Core 'single' shortcodes including {SETIMAGE}
### Related 'item' - Options: {RELATED_URL} {RELATED_IMAGE} {RELATED_TITLE} {RELATED_SUMMARY}
### Related 'end' - Options: Options: Core 'single' shortcodes including {SETIMAGE}
$NEWS_TEMPLATE['related']['start'] = "<hr><h4>".defset('LAN_RELATED', 'Related')."</h4><ul class='e-related'>";
$NEWS_TEMPLATE['related']['item'] = "<li><a href='{RELATED_URL}'>{RELATED_TITLE}</a></li>";
$NEWS_TEMPLATE['related']['end'] = "</ul>";

View File

@@ -72,8 +72,8 @@ class page_related // replace 'e_' with 'plugin-folder_'
$items[] = array( $items[] = array(
'title' => $title, 'title' => $title,
'url' => e107::getUrl()->create('page/view/index',$row), // '{e_BASE}news.php?extend.'.$row['news_id'], 'url' => e107::getUrl()->create('page/view/index',$row), // '{e_BASE}news.php?extend.'.$row['news_id'],
'body' => $row['news_summary'], 'summary' => $row['page_metadescr'],
'image' => $row['news_image'] 'image' => $row['menu_image']
); );
} }