From 16dc9d39b6cba42623aa78ba70f5af40fc9dd4b8 Mon Sep 17 00:00:00 2001
From: Cameron
Date: Wed, 22 Jan 2014 06:14:23 -0800
Subject: [PATCH] Added new e_related addon and updated default news and page
templates to utilize.
---
.../shortcodes/batch/news_shortcodes.php | 12 ++++++
.../shortcodes/batch/page_shortcodes.php | 10 ++++-
e107_core/templates/page_template.php | 6 +--
e107_handlers/form_handler.php | 43 +++++++++++++++++++
e107_plugins/news/templates/news_template.php | 3 +-
5 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php
index f50d2c947..b2c4e348f 100644
--- a/e107_core/shortcodes/batch/news_shortcodes.php
+++ b/e107_core/shortcodes/batch/news_shortcodes.php
@@ -526,6 +526,18 @@ class news_shortcodes extends e_shortcode
return "None";
}
}
+
+
+
+ function sc_newsrelated($array=array())
+ {
+ if(!varset($array['types']))
+ {
+ $array['types'] = 'news,page';
+ }
+
+ return e107::getForm()->renderRelated($array['types'], $this->news_item['news_meta_keywords'], array('news'=>$this->news_item['news_id']));
+ }
}
?>
diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php
index 757831bf2..8576c49bd 100644
--- a/e107_core/shortcodes/batch/page_shortcodes.php
+++ b/e107_core/shortcodes/batch/page_shortcodes.php
@@ -372,7 +372,15 @@ class cpage_shortcodes extends e_shortcode
-
+ function sc_cpagerelated($array=array())
+ {
+ if(!varset($array['types']))
+ {
+ $array['types'] = 'page,news';
+ }
+
+ return e107::getForm()->renderRelated($array['types'], $this->page['page_metakeys'], array('page'=>$this->page['page_id']));
+ }
diff --git a/e107_core/templates/page_template.php b/e107_core/templates/page_template.php
index 3a27e60ba..9b4da3668 100644
--- a/e107_core/templates/page_template.php
+++ b/e107_core/templates/page_template.php
@@ -27,6 +27,8 @@ $sc_style['CPAGENAV|default']['post'] = '';
#### default template - BC ####
// used only for parsing comment outside of the page tablerender-ed content
// leave empty if you integrate page comments inside the main page template
+
+
$PAGE_TEMPLATE['default']['page'] = '
{PAGE}
{PAGECOMMENTS}
@@ -39,7 +41,6 @@ $sc_style['CPAGENAV|default']['post'] = '';
$PAGE_TEMPLATE['default']['body'] = '
{CPAGEMESSAGE|default}
- {CPAGEAUTHOR|default}{CPAGEDATE|default}
{CPAGESUBTITLE|default}
@@ -72,7 +73,7 @@ $sc_style['CPAGENAV|default']['post'] = '';
';
// always used
- $PAGE_TEMPLATE['default']['end'] = '';
+ $PAGE_TEMPLATE['default']['end'] = '{CPAGERELATED: types=page,news}';
// options per template - disable table render
// $PAGE_TEMPLATE['default']['noTableRender'] = false; //XXX Deprecated
@@ -91,7 +92,6 @@ $sc_style['CPAGENAV|default']['post'] = '';
';
$PAGE_TEMPLATE['custom']['end'] = '';
-// $PAGE_TEMPLATE['custom']['noTableRender'] = true; //XXX Deprecated
$PAGE_TEMPLATE['custom']['tableRender'] = '';
diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php
index dcbf31419..b47864423 100644
--- a/e107_handlers/form_handler.php
+++ b/e107_handlers/form_handler.php
@@ -2225,8 +2225,51 @@ class e_form
return $text;
}
+
+
+
+ /**
+ * Render Related Items for the current page/news-item etc.
+ * @param string $type : comma separated list. ie. plugin folder names.
+ * @param string $tags : comma separated list of keywords to return related items of.
+ * @param array $curVal. eg. array('page'=> current-page-id-value);
+ */
+ function renderRelated($type='news',$tags, $curVal) //XXX TODO Cache!
+ {
+ $parm = array('limit' => 5);
+ $tp = e107::getParser();
+
+ $types = explode(',',$type);
+ foreach($types as $plug)
+ {
+
+ if(!$obj = e107::getAddon($plug,'e_related'))
+ {
+ continue;
+ }
+
+ $parm['current'] = intval(varset($curVal[$plug]));
+
+ $tmp = $obj->compile($tags,$parm);
+
+ if(count($tmp))
+ {
+ foreach($tmp as $val)
+ {
+ $list[] = "".$val['title']."";
+
+ }
+ }
+ }
+
+ if(count($list))
+ {
+ return ""; //XXX Tablerender?
+ }
+
+ }
diff --git a/e107_plugins/news/templates/news_template.php b/e107_plugins/news/templates/news_template.php
index 7f1103221..4c8f38e6a 100644
--- a/e107_plugins/news/templates/news_template.php
+++ b/e107_plugins/news/templates/news_template.php
@@ -44,7 +44,7 @@ $NEWS_TEMPLATE['list']['item'] = '
-
+
';
@@ -135,6 +135,7 @@ $NEWS_TEMPLATE['view']['item'] = '
{GLYPH=comments} {NEWSCOMMENTCOUNT} {EMAILICON} {PRINTICON} {PDFICON} {ADMINOPTIONS}
+ {NEWSRELATED}
';
//$NEWS_MENU_TEMPLATE['view']['separator'] = '
';