mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
Allow shortcode to limit results in e_related.
This commit is contained in:
parent
846cbec7f9
commit
6167544d50
@ -536,7 +536,7 @@ class news_shortcodes extends e_shortcode
|
|||||||
$array['types'] = 'news,page';
|
$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']));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ class cpage_shortcodes extends e_shortcode
|
|||||||
$array['types'] = 'page,news';
|
$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']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2235,12 +2235,22 @@ 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($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();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
$types = explode(',',$type);
|
$types = explode(',',$parm['types']);
|
||||||
$list = array();
|
$list = array();
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,18 +19,20 @@ class page_related // replace 'e_' with 'plugin-folder_'
|
|||||||
{
|
{
|
||||||
private $chapterSef = array();
|
private $chapterSef = array();
|
||||||
private $chapterParent = array();
|
private $chapterParent = array();
|
||||||
|
private $chapterName = array();
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
$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)
|
foreach($books as $row)
|
||||||
{
|
{
|
||||||
$id = $row['chapter_id'];
|
$id = $row['chapter_id'];
|
||||||
$this->chapterSef[$id] = $row['chapter_sef'];
|
$this->chapterSef[$id] = $row['chapter_sef'];
|
||||||
$this->chapterParent[$id] = $row['chapter_parent'];
|
$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']);
|
$book = $this->getParent($row['page_chapter']);
|
||||||
$row['book_sef'] = $this->getSef($book);
|
$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(
|
$items[] = array(
|
||||||
'title' => $row['page_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'],
|
'body' => $row['news_summary'],
|
||||||
'image' => $row['news_image']
|
'image' => $row['news_image']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user