Next/Previous Buttons for Articles
wright 42
From: -
From: -
Notice
This topic is archived. New comments cannot be posted and votes cannot be cast.Responses to this topic
1 Re: Next/Previous Buttons for Articles
wright
OP
42
From: -
From: -
Perfect thanks.
1 Re: Next/Previous Buttons for Articles
Philipp Esselbach
From: -
Editor
0From: -
Sorry, it should be articlepage_page and not articlepage_id:
global $database;
$result = $database -> dbquery("SELECT articlepage_page FROM " . DB_PREFIX . "esselbach_ct_articlespages WHERE articlepage_article = '" . $insert[ 'article_id' ] . "' AND articlepage_page < '" . $insert[ 'articlepage_page' ] . "' ORDER BY articlepage_page DESC LIMIT 1");
if ($database -> dbrows($result)) {
list($previous) = $database -> dbrow($result);
$previous_page = "<a href=\"contentteller".$insert['param_ext'].$insert['param_ct']."articles".$insert['param_action']."pages".$insert['param_page'].$insert['article_seo'].",".$previous.".html\">Previous Page</a>";
} else {
$previous_page = "";
}
$result = $database -> dbquery("SELECT articlepage_page FROM " . DB_PREFIX . "esselbach_ct_articlespages WHERE articlepage_article = '" . $insert[ 'article_id' ] . "' AND articlepage_page > '" . $insert[ 'articlepage_page' ] . "' ORDER BY articlepage_page LIMIT 1");
if ($database -> dbrows($result)) {
list($next) = $database -> dbrow($result);
$next_page ="<a href=\"contentteller".$insert['param_ext'].$insert['param_ct']."articles".$insert['param_action']."pages".$insert['param_page'].$insert['article_seo'].",".$next.".html\">Next Page</a>";
} else {
$next_page = "";
}
1 Re: Next/Previous Buttons for Articles
wright
OP
42
From: -
From: -
I am not sure if I did something wrong but when you click next it doesn't work...
rather than go to "intel_core_i5_661_core_i3_540,2.html" it does something like "intel_core_i5_661_core_i3_540,728.html"
rather than go to "intel_core_i5_661_core_i3_540,2.html" it does something like "intel_core_i5_661_core_i3_540,728.html"
1 Re: Next/Previous Buttons for Articles
Philipp Esselbach
From: -
Editor
0From: -
Open the template articles_pages in the template editor and add the following PHP part:
Now you can use the variables {$next_page} and {$previous_page} in the HTML part for the next and previous links.
Example:
global $database;
$result = $database -> dbquery("SELECT articlepage_id FROM " . DB_PREFIX . "esselbach_ct_articlespages WHERE articlepage_article = '" . $insert[ 'article_id' ] . "' AND articlepage_page < '" . $insert[ 'articlepage_page' ] . "' ORDER BY articlepage_id DESC LIMIT 1");
if ($database -> dbrows($result)) {
list($previous) = $database -> dbrow($result);
$previous_page = "<a href=\"contentteller".$insert['param_ext'].$insert['param_ct']."articles".$insert['param_action']."pages".$insert['param_page'].$insert['article_seo'].",".$previous.".html\">Previous Page</a>";
} else {
$previous_page = "";
}
$result = $database -> dbquery("SELECT articlepage_id FROM " . DB_PREFIX . "esselbach_ct_articlespages WHERE articlepage_article = '" . $insert[ 'article_id' ] . "' AND articlepage_page > '" . $insert[ 'articlepage_page' ] . "' ORDER BY articlepage_id LIMIT 1");
if ($database -> dbrows($result)) {
list($next) = $database -> dbrow($result);
$next_page ="<a href=\"contentteller".$insert['param_ext'].$insert['param_ct']."articles".$insert['param_action']."pages".$insert['param_page'].$insert['article_seo'].",".$next.".html\">Next Page</a>";
} else {
$next_page = "";
}
Now you can use the variables {$next_page} and {$previous_page} in the HTML part for the next and previous links.
Example:
<!-- Template: articles_pages -->
<h1>{$insert['article_title']} {$insert['article_edit']} {$insert['article_rating_line']}</h1>
<h2>Posted by: {$insert['article_author']} on: {$insert['article_date']} [ <a href="https://www.contentteller.com/contentteller{$insert['param_ext']}{$insert['param_ct']}articles{$insert['param_action']}pagesprinter{$insert['param_page']}{$insert['article_seo']},{$insert['articlepage_page']}.html" rel="nofollow">Print</a> | <a href="https://www.contentteller.com/contentteller{$insert['param_ext']}{$insert['param_ct']}articles{$insert['param_action']}summary{$insert['param_page']}{$insert['article_seo']}.html">{$insert['article_comments']} comment(s)</a> ]</h2>
<div class="content">{$insert['article_teaserimage']}{$insert['articles_pages_title']}{$insert['articlepage_text']}{$insert['article_toc']}{$insert['article_social']}<br /><br /><div style="text-align: center;">{$previous_page} {$next_page}</div></div>
<br />
1 Re: Next/Previous Buttons for Articles
wright
OP
42
From: -
From: -
Sorry page
1 Re: Next/Previous Buttons for Articles
Philipp Esselbach
From: -
Editor
0From: -
Next/previous article or page?
How can I add a next/previous button to the articles?