mirror of
https://github.com/e107inc/e107.git
synced 2025-08-18 20:31:41 +02:00
Optimized News listing pages for less SQL lookups. Enhancement: News article listing by author.
This commit is contained in:
@@ -291,6 +291,27 @@ class news_shortcodes extends e_shortcode
|
||||
return $this->sc_newsauthor($parm);
|
||||
}
|
||||
|
||||
public function sc_news_author_avatar($parm=null)
|
||||
{
|
||||
return $this->sc_newsavatar($parm);
|
||||
}
|
||||
|
||||
public function sc_news_author_signature($parm=null)
|
||||
{
|
||||
|
||||
$user = e107::user($this->news_item['user_id']);
|
||||
|
||||
if(!empty($user['user_signature']))
|
||||
{
|
||||
return e107::getParser()->toHtml($user['user_signature'], true, 'DESCRIPTION');
|
||||
}
|
||||
}
|
||||
|
||||
public function sc_news_author_items_url($parm=null)
|
||||
{
|
||||
return e107::getUrl()->create('news/list/author',array('author'=>$this->news_item['user_name'])); // e_BASE."news.php?author=".$val
|
||||
}
|
||||
|
||||
public function sc_news_summary($parm=null)
|
||||
{
|
||||
return $this->sc_newssummary($parm);
|
||||
@@ -369,7 +390,10 @@ class news_shortcodes extends e_shortcode
|
||||
|
||||
function sc_newsavatar($parm=null)
|
||||
{
|
||||
return vartrue($this->news_item['user_id']) ? e107::getParser()->parseTemplate("{USER_AVATAR=".$this->news_item['user_id']."}",true) : '';
|
||||
if(!empty($this->news_item['user_id']))
|
||||
{
|
||||
return e107::getParser()->toAvatar($this->news_item['user_id'], $parm);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -39,8 +39,9 @@ class core_news_sef_full_url extends eUrlConfig
|
||||
'Short/<id:{number}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id'), 'legacyQuery' => 'cat.{id}.{page}'),
|
||||
'Day/<id:{number}>' => array('list/day', 'allowVars' => array('page'), 'legacyQuery' => 'day.{id}.{page}'),
|
||||
'Month/<id:{number}>' => array('list/month', 'allowVars' => array('page'), 'legacyQuery' => 'month.{id}.{page}'),
|
||||
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}'),
|
||||
|
||||
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}&page={page}'),
|
||||
'Author/<author:{secure}>' => array('list/author', 'allowVars' => array('page'), 'legacyQuery' => 'author={author}&page={$page}'),
|
||||
|
||||
'<category:{sefsecure}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('category_sef' => 'category', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
|
||||
'<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
|
||||
'<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
|
||||
|
@@ -102,7 +102,14 @@ class core_news_sef_noid_url extends eUrlConfig
|
||||
|
||||
case 'tag': // news/tag/xxxx
|
||||
$r[0] = 'tag';
|
||||
$r[1] = $params['tag'];
|
||||
$r[1] = $params['tag'];
|
||||
if($page) $parm = array('page' => $page);
|
||||
break;
|
||||
|
||||
case 'author': // news/author/xxxx
|
||||
$r[0] = 'author';
|
||||
$r[1] = $params['author'];
|
||||
if($page) $parm = array('page' => $page);
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
@@ -250,6 +257,11 @@ class core_news_sef_noid_url extends eUrlConfig
|
||||
$this->legacyQueryString = 'tag='.$parts[1];
|
||||
return 'list/tag';
|
||||
break;
|
||||
|
||||
case 'author': // url: news/author/xxxxx
|
||||
$this->legacyQueryString = 'author='.$parts[1].'&page='.$page;
|
||||
return 'list/author';
|
||||
break;
|
||||
|
||||
# force not found
|
||||
default:
|
||||
|
@@ -107,9 +107,9 @@ class core_news_sef_url extends eUrlConfig
|
||||
|
||||
'View/<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
|
||||
|
||||
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}'),
|
||||
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}&page={page}'),
|
||||
|
||||
|
||||
'Author/<author:{secure}>' => array('list/author', 'allowVars' => array('page'), 'legacyQuery' => 'author={author}&page={page}'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@@ -134,8 +134,8 @@ class core_news_url extends eUrlConfig
|
||||
$url .= 'default.0.'.$page;
|
||||
}
|
||||
else
|
||||
{
|
||||
$url .= 'list.'.$params['id'].'.'.$page; // 'category_id' would break news_categories_menu.
|
||||
{
|
||||
$url .= 'list.'.$params['id'].'.'.$page; // 'category_id' would break news_categories_menu.
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -146,6 +146,10 @@ class core_news_url extends eUrlConfig
|
||||
case 'tag':
|
||||
$url .= 'tag='.$params['tag'].'&page='.$page;
|
||||
break;
|
||||
|
||||
case 'author':
|
||||
$url .= 'author='.$params['author'].'&page='.$page;
|
||||
break;
|
||||
|
||||
case 'short':
|
||||
$url .= 'cat.'.$params['id'].'.'.$page;
|
||||
|
Reference in New Issue
Block a user