mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 04:32:01 +02:00
Added new e_related addon and updated default news and page templates to utilize.
This commit is contained in:
parent
7679b5e075
commit
16dc9d39b6
@ -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']));
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -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']));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
|
||||
#### 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'] = '</div>';
|
||||
$PAGE_TEMPLATE['default']['body'] = '
|
||||
{CPAGEMESSAGE|default}
|
||||
|
||||
<div class="f-right">{CPAGEAUTHOR|default}{CPAGEDATE|default}</div>
|
||||
{CPAGESUBTITLE|default}
|
||||
<div class="clear"><!-- --></div>
|
||||
|
||||
@ -72,7 +73,7 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
|
||||
';
|
||||
|
||||
// always used
|
||||
$PAGE_TEMPLATE['default']['end'] = '</div>';
|
||||
$PAGE_TEMPLATE['default']['end'] = '{CPAGERELATED: types=page,news}</div>';
|
||||
|
||||
// options per template - disable table render
|
||||
// $PAGE_TEMPLATE['default']['noTableRender'] = false; //XXX Deprecated
|
||||
@ -91,7 +92,6 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
|
||||
';
|
||||
|
||||
$PAGE_TEMPLATE['custom']['end'] = '</div>';
|
||||
// $PAGE_TEMPLATE['custom']['noTableRender'] = true; //XXX Deprecated
|
||||
$PAGE_TEMPLATE['custom']['tableRender'] = '';
|
||||
|
||||
|
||||
|
@ -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[] = "<li><a href='".$tp->replaceConstants($val['url'],'full')."'>".$val['title']."</a></li>";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
return "<div class='e-related'><hr><h4>Related</h4><ul class='e-related'>".implode("\n",$list)."</ul></div>"; //XXX Tablerender?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ $NEWS_TEMPLATE['list']['item'] = '
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
';
|
||||
|
||||
|
||||
@ -135,6 +135,7 @@ $NEWS_TEMPLATE['view']['item'] = '
|
||||
<span class="category ">{GLYPH=comments} {NEWSCOMMENTCOUNT} {EMAILICON} {PRINTICON} {PDFICON} {ADMINOPTIONS}</span>
|
||||
</div>
|
||||
</div>
|
||||
{NEWSRELATED}
|
||||
';
|
||||
//$NEWS_MENU_TEMPLATE['view']['separator'] = '<br />';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user