1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Allow shortcode to limit results in e_related.

This commit is contained in:
Cameron 2014-01-22 08:35:35 -08:00
parent 846cbec7f9
commit 6167544d50
4 changed files with 21 additions and 7 deletions

View File

@ -536,7 +536,7 @@ class news_shortcodes extends e_shortcode
$array['types'] = 'news,page';
}
return e107::getForm()->renderRelated($array['types'], $this->news_item['news_meta_keywords'], array('news'=>$this->news_item['news_id']));
return e107::getForm()->renderRelated($array, $this->news_item['news_meta_keywords'], array('news'=>$this->news_item['news_id']));
}
}

View File

@ -379,7 +379,7 @@ class cpage_shortcodes extends e_shortcode
$array['types'] = 'page,news';
}
return e107::getForm()->renderRelated($array['types'], $this->page['page_metakeys'], array('page'=>$this->page['page_id']));
return e107::getForm()->renderRelated($array, $this->page['page_metakeys'], array('page'=>$this->page['page_id']));
}

View File

@ -2235,12 +2235,22 @@ class e_form
* @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!
function renderRelated($parm,$tags, $curVal) //XXX TODO Cache!
{
$parm = array('limit' => 5);
if(!varset($parm['limit']))
{
$parm = array('limit' => 5);
}
if(!varset($parm['types']))
{
$parm['types'] = 'news';
}
$tp = e107::getParser();
$types = explode(',',$type);
$types = explode(',',$parm['types']);
$list = array();

View File

@ -19,18 +19,20 @@ class page_related // replace 'e_' with 'plugin-folder_'
{
private $chapterSef = array();
private $chapterParent = array();
private $chapterName = array();
function __construct()
{
$sql = e107::getDb();
$books = $sql->retrieve("SELECT chapter_id,chapter_sef,chapter_parent FROM #page_chapters ORDER BY chapter_id ASC" , true);
$books = $sql->retrieve("SELECT chapter_id,chapter_sef,chapter_parent,chapter_name FROM #page_chapters ORDER BY chapter_id ASC" , true);
foreach($books as $row)
{
$id = $row['chapter_id'];
$this->chapterSef[$id] = $row['chapter_sef'];
$this->chapterParent[$id] = $row['chapter_parent'];
$this->chapterName[$id] = $row['chapter_name'];
}
}
@ -64,9 +66,11 @@ class page_related // replace 'e_' with 'plugin-folder_'
$book = $this->getParent($row['page_chapter']);
$row['book_sef'] = $this->getSef($book);
$id = $row['page_chapter'];
$title = (vartrue($this->chapterName[$id])) ? $this->chapterName[$id]." | ".$row['page_title'] : $row['page_title'];
$items[] = array(
'title' => $row['page_title'],
'title' => $title,
'url' => e107::getUrl()->create('page/view/index',$row), // '{e_BASE}news.php?extend.'.$row['news_id'],
'body' => $row['news_summary'],
'image' => $row['news_image']