This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

Next/Previous Buttons for Articles


avatar
wright 42
From: -
Next/Previous Buttons for Articles

How can I add a next/previous button to the articles?

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
avatar
OP 42
From: -
Perfect thanks.
1 Re: Next/Previous Buttons for Articles
avatar
Editor
0
From: -
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
avatar
OP 42
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"
1 Re: Next/Previous Buttons for Articles
avatar
Editor
0
From: -
Open the template articles_pages in the template editor and add the following PHP part:

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
avatar
OP 42
From: -
Sorry page
1 Re: Next/Previous Buttons for Articles
avatar
Editor
0
From: -
Next/previous article or page?

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.