Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: previous article and next article links  (Read 7474 times)

NaEnr

  • Newbie
  • *
  • Karma: 10
  • Posts: 9
previous article and next article links
« on: May 20, 2008, 09:16:36 PM »

Update 2008-06-15

Demo:


-----------------------------------------------------------------------------------------------------------------

Step 1: add code in snews.php:

Code: [Select]
function fast_links() {
$categorySEF = get_id('category'); $articleSEF = get_id('article');
if (strpos($articleSEF, l('paginator')) === 0) {$articleSEF = str_replace(l('paginator'), '', $articleSEF);}
$query = "SELECT id FROM ".db('prefix')."articles WHERE seftitle = '$articleSEF'";
$result = mysql_query($query);
  while ($r = mysql_fetch_array($result)) {
$articleId = $r['id'];
echo '<div id="fast_links">';
$query = "SELECT * FROM ".db('prefix')."articles WHERE id < $articleId ORDER BY id DESC LIMIT 1";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
echo '<p>'.l('previous_article').l('none').'</p>';
} else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$categorySEF = find_cat_sef($r['category']);
echo '<p>'.l('previous_article').' <a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a></p>';
}
}
$query = "SELECT * FROM ".db('prefix')."articles WHERE id > $articleId ORDER BY id LIMIT 1";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
echo '<p>'.l('next_article').l('none').'</p>';
} else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$categorySEF = find_cat_sef($r['category']);
echo '<p>'.l('next_article').' <a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a></p>';
}
}
echo '</div>';
}
}

Then add: code in index.php
Code: [Select]
<?php fast_links(); ?>

Step 2:   Add language

Code: [Select]
#fast links
 $l['previous_article'] = 'Previous Article: ';
 $l['next_article'] = 'Next Article: ';
 $l['none'] = 'None';
« Last Edit: June 14, 2008, 11:35:22 PM by NaEnr »
Logged

sNews Chinese

  • Newbie
  • *
  • Karma: 4
  • Posts: 34
  • www.snewscms.net
    • sNewsCMS Network
Re: previous article and next article links
« Reply #1 on: May 30, 2008, 12:57:14 PM »

I have joined you QQ!
Logged

carl

  • Guest
Re: previous article and next article links
« Reply #2 on: May 30, 2008, 01:06:37 PM »

Removed post - Post in english next time.
« Last Edit: May 30, 2008, 02:19:21 PM by Patric Ahlqvist »
Logged

NaEnr

  • Newbie
  • *
  • Karma: 10
  • Posts: 9
Re: previous article and next article links
« Reply #3 on: June 14, 2008, 11:06:22 PM »

Already Editor
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: previous article and next article links
« Reply #4 on: September 11, 2008, 05:08:56 PM »

Karma + has been delivered here.
Thanks.
Just a question: it's not only articles but pages which can be browsed this way.
How to avoid having pages displayed?

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru
Re: previous article and next article links
« Reply #5 on: September 11, 2008, 09:46:30 PM »

Here, Sven:

Code: [Select]
function fast_links() {
$categorySEF = get_id('category'); $articleSEF = get_id('article');
if (strpos($articleSEF, l('paginator')) === 0) {$articleSEF = str_replace(l('paginator'), '', $articleSEF);}
$query = "SELECT id FROM ".db('prefix')."articles WHERE seftitle = '$articleSEF' AND SUBSTRING(position, 1, 1) != 2 AND position <> 3";
$result = mysql_query($query);
  while ($r = mysql_fetch_array($result)) {
$articleId = $r['id'];
echo '<div id="fast_links">';
$query = "SELECT * FROM ".db('prefix')."articles WHERE id < $articleId AND SUBSTRING(position, 1, 1) != 2 AND position <> 3 ORDER BY id DESC LIMIT 1";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
echo '<p>'.l('previous_article').l('none').'</p>';
} else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$categorySEF = find_cat_sef($r['category']);
echo '<p>'.l('previous_article').' <a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a></p>';
}
}
$query = "SELECT * FROM ".db('prefix')."articles WHERE id > $articleId AND SUBSTRING(position, 1, 1) != 2 AND position <> 3 ORDER BY id LIMIT 1";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
echo '<p>'.l('next_article').l('none').'</p>';
} else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$categorySEF = find_cat_sef($r['category']);
echo '<p>'.l('next_article').' <a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a></p>';
}
}
echo '</div>';
}
}
Logged
Now ogres, oh, they're much worse. They'll make a suit from your freshly peeled skin. They'll shave your liver, squeeze the jelly from your eyes... Actually, it's quite good on toast.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: previous article and next article links
« Reply #6 on: September 12, 2008, 09:38:28 AM »

Hello dear ogre
nice to see you pal!
Thanks a lot for the code which is gonna be updated in the few next hours.
I'll be back to tell if it works (but I'm pretty sure it will)
While, eat that Karma +.
I know ogres desserve them. ;D

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: previous article and next article links
« Reply #7 on: September 12, 2008, 10:55:09 AM »

Remote control works perfectly!
Thanks a lot my dear ogre.
Thanks too NaEnr.
Nice Mod for visitors: they can browse the articles chronologically.

For a demo you can visit The birth of the Internet,
and browse the blog via the remote.

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru
Re: previous article and next article links
« Reply #8 on: September 12, 2008, 01:33:34 PM »

Remote control works perfectly!
Thanks a lot my dear ogre.
Thanks too NaEnr.
Nice Mod for visitors: they can browse the articles chronologically.

For a demo you can visit The birth of the Internet,
and browse the blog via the remote.

Also try this updated code. It's a little optimized. No reversed check for articles - only direct position check. Fetching only needed columns.

Code: [Select]
function fast_links() {
$categorySEF = get_id('category'); $articleSEF = get_id('article');
if (strpos($articleSEF, l('paginator')) === 0) {$articleSEF = str_replace(l('paginator'), '', $articleSEF);}
$query = "SELECT id FROM ".db('prefix')."articles WHERE seftitle = '$articleSEF' AND position = 1";
$result = mysql_query($query);
  while ($r = mysql_fetch_array($result)) {
$articleId = $r['id'];
echo '<div id="fast_links">';
$query = "SELECT id,title,seftitle,category FROM ".db('prefix')."articles WHERE id < $articleId AND position = 1 ORDER BY id DESC LIMIT 1";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
echo '<p>'.l('previous_article').l('none').'</p>';
} else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$categorySEF = find_cat_sef($r['category']);
echo '<p>'.l('previous_article').' <a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a></p>';
}
}
$query = "SELECT id,title,seftitle,category FROM ".db('prefix')."articles WHERE id > $articleId AND position = 1 ORDER BY id LIMIT 1";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
echo '<p>'.l('next_article').l('none').'</p>';
} else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$categorySEF = find_cat_sef($r['category']);
echo '<p>'.l('next_article').' <a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a></p>';
}
}
echo '</div>';
}
}
Logged
Now ogres, oh, they're much worse. They'll make a suit from your freshly peeled skin. They'll shave your liver, squeeze the jelly from your eyes... Actually, it's quite good on toast.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: previous article and next article links
« Reply #9 on: September 12, 2008, 03:40:03 PM »

You came back for another Karma, dear ogre? ;D
Fully optimized now!!!
Thanks you so much Armen.
I really appreciate.

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: previous article and next article links
« Reply #10 on: September 13, 2008, 12:31:10 AM »

For a demo you can visit The birth of the Internet,
and browse the blog via the remote.

I need to learn French to understand the Internet... ???

:lol:

Du bon travail sur ce site et l'<précédente suivante> modification.
Logged
Yes! I have no siggy.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: previous article and next article links
« Reply #11 on: September 13, 2008, 09:11:06 AM »

I need to learn French to understand the Internet... ???
Not at all ;)
Du bon travail sur ce site et l'<précédente suivante> modification.
Thanks pal. The remote is a very very good idea. Thanks to NaEnr for the Mod and to Armen for the light version.

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: previous article and next article links
« Reply #12 on: September 13, 2008, 05:28:45 PM »

Karmas to both of them...
Logged
Yes! I have no siggy.

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 381
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: previous article and next article links
« Reply #13 on: April 27, 2009, 04:58:01 AM »

This mods author requires a karma. Thank you NaEnr and also thank you Armen! :)
Logged
By(e) Henrich :)
------------------------------
IT related blog

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: previous article and next article links
« Reply #14 on: August 30, 2009, 10:31:24 AM »

Uh oh...
what should I change to make it 1.7?
(yeap I didn't read the fucking manual) ;D
Pages: [1] 2