mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Issue #4024 - Pagination url option added to News preferences. Select between 'record' (legacy format eg. page=20, page=40 etc) or 'page' numbers (page=1, page=2 etc). Experimental - requires more testing.
This commit is contained in:
@@ -955,6 +955,7 @@ class news_admin_ui extends e_admin_ui
|
|||||||
$temp['news_newdateheader'] = intval($_POST['news_newdateheader']);
|
$temp['news_newdateheader'] = intval($_POST['news_newdateheader']);
|
||||||
$temp['news_unstemplate'] = intval($_POST['news_unstemplate']);
|
$temp['news_unstemplate'] = intval($_POST['news_unstemplate']);
|
||||||
$temp['news_editauthor'] = intval($_POST['news_editauthor']);
|
$temp['news_editauthor'] = intval($_POST['news_editauthor']);
|
||||||
|
$temp['news_pagination'] = filter_var($_POST['news_pagination']);
|
||||||
|
|
||||||
$temp['news_default_template'] = preg_replace('#[^\w\pL\-]#u', '', $_POST['news_default_template']);
|
$temp['news_default_template'] = preg_replace('#[^\w\pL\-]#u', '', $_POST['news_default_template']);
|
||||||
$temp['news_list_limit'] = intval($_POST['news_list_limit']);
|
$temp['news_list_limit'] = intval($_POST['news_list_limit']);
|
||||||
@@ -1054,6 +1055,16 @@ class news_admin_ui extends e_admin_ui
|
|||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
$paginationOpts = ['record'=> "Record", 'page'=>'Page'];
|
||||||
|
|
||||||
|
$tab1 .= "
|
||||||
|
<tr>
|
||||||
|
<td>".LAN_PAGINATION.$frm->help(LAN_NEWS_112)."</td>
|
||||||
|
<td>
|
||||||
|
".$frm->select('news_pagination',$paginationOpts, varset($pref['news_pagination'],'record'))."
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
|
||||||
|
|
||||||
$tab1 .= "
|
$tab1 .= "
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -31,6 +31,8 @@ class news_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
private $imageItem;
|
private $imageItem;
|
||||||
|
|
||||||
|
protected $pagination;
|
||||||
|
|
||||||
|
|
||||||
// protected $param; // do not enable - erases param. .
|
// protected $param; // do not enable - erases param. .
|
||||||
|
|
||||||
@@ -44,6 +46,8 @@ class news_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
$this->commentsDisabled = vartrue($pref['comments_disabled']);
|
$this->commentsDisabled = vartrue($pref['comments_disabled']);
|
||||||
|
|
||||||
|
$this->pagination = varset($pref['news_pagination'], 'record');
|
||||||
|
|
||||||
if(!empty($pref['comments_engine']))
|
if(!empty($pref['comments_engine']))
|
||||||
{
|
{
|
||||||
$this->commentsEngine = $pref['comments_engine'];
|
$this->commentsEngine = $pref['comments_engine'];
|
||||||
@@ -1207,7 +1211,16 @@ class news_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
$params = e107::getRegistry('core/news/pagination');
|
$params = e107::getRegistry('core/news/pagination');
|
||||||
|
|
||||||
return e107::getParser()->parseTemplate("{NEXTPREV=".$params."}");
|
parse_str($params,$opts);
|
||||||
|
|
||||||
|
if($this->pagination === 'page')
|
||||||
|
{
|
||||||
|
$opts['type'] = 'page';
|
||||||
|
$opts['total'] = ceil($opts['total'] / $opts['amount']);
|
||||||
|
$opts['current'] = ($opts['current'] / $opts['amount']) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return e107::getParser()->parseTemplate("{NEXTPREV=".http_build_query($opts)."}");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -223,6 +223,7 @@
|
|||||||
<core name="news_default_template">default</core>
|
<core name="news_default_template">default</core>
|
||||||
<core name="news_list_limit">10</core>
|
<core name="news_list_limit">10</core>
|
||||||
<core name="news_newdateheader">0</core>
|
<core name="news_newdateheader">0</core>
|
||||||
|
<core name="news_pagination">record</core>
|
||||||
<core name="newsposts">10</core>
|
<core name="newsposts">10</core>
|
||||||
<core name="newsposts_archive">0</core>
|
<core name="newsposts_archive">0</core>
|
||||||
<core name="newsposts_archive_title"></core>
|
<core name="newsposts_archive_title"></core>
|
||||||
|
@@ -581,4 +581,5 @@ define("LAN_ROBOTS_NOIMAGE", "Prevent search engines from indexing images of thi
|
|||||||
|
|
||||||
define("LAN_NAVIGATION", "Navigation");
|
define("LAN_NAVIGATION", "Navigation");
|
||||||
define("LAN_NAVIGATION_LINKS", "Navigation Links");
|
define("LAN_NAVIGATION_LINKS", "Navigation Links");
|
||||||
|
define("LAN_PAGINATION", "Pagination");
|
||||||
|
|
||||||
|
@@ -237,3 +237,4 @@ define("LAN_NEWS_108", "The SEF URL is unlike the title of your news item.");
|
|||||||
define("LAN_NEWS_109", "Trigger an email notification when you submit this form.");
|
define("LAN_NEWS_109", "Trigger an email notification when you submit this form.");
|
||||||
define("LAN_NEWS_110", "News Cache Timeout");
|
define("LAN_NEWS_110", "News Cache Timeout");
|
||||||
define("LAN_NEWS_111", "Time in minutes. Applies only when system cache is enabled.");
|
define("LAN_NEWS_111", "Time in minutes. Applies only when system cache is enabled.");
|
||||||
|
define("LAN_NEWS_112", "Select the URL format. Either record count (eg. page=20, page=40, page=60 etc.) or page number (eg. page=1, page=2, page=3 etc.). Warning: If modified some news URLs will need to be re-indexed by search engines.");
|
||||||
|
@@ -403,7 +403,16 @@ class news_front
|
|||||||
$this->newsUrlparms['author'] = $tp->filter($_GET['author']);
|
$this->newsUrlparms['author'] = $tp->filter($_GET['author']);
|
||||||
$this->from = intval(varset($_GET['page'],0));
|
$this->from = intval(varset($_GET['page'],0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New in v2.3.1 Pagination with "Page" instead of "Record".
|
||||||
|
if(!empty($this->pref['news_pagination']) && $this->pref['news_pagination'] === 'page' && !empty($_GET['page']))
|
||||||
|
{
|
||||||
|
$this->from = (int) ($_GET['page'] - 1) * ITEMVIEW;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1083,7 +1092,6 @@ class news_front
|
|||||||
$url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms));
|
$url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms));
|
||||||
$parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url;
|
$parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url;
|
||||||
|
|
||||||
|
|
||||||
$this->addDebug('newsUrlParms',$this->newsUrlparms);
|
$this->addDebug('newsUrlParms',$this->newsUrlparms);
|
||||||
|
|
||||||
$paginationSC = false;
|
$paginationSC = false;
|
||||||
|
Reference in New Issue
Block a user