Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: 1 [2]

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

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: previous article and next article links
« Reply #15 on: August 30, 2009, 04:21:13 PM »

You wont even try?
Gonna read it now nukpana, and try this Mod for 1.7.
Thanks a lot pal.
Did I ever give you a karma?

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: previous article and next article links
« Reply #16 on: August 30, 2009, 08:03:36 PM »

Gonna read it now nukpana, and try this Mod for 1.7.
Thanks a lot pal.
Did I ever give you a karma?

No, you didn't - thank you.

Here is my test run at the 1.7 version of the mod.  You will need the language files from the first post.
It doesn't work as expected per the first post screenshots, but I raced through this...

--- updated code http://snewscms.com/forum/index.php?topic=8623.msg61059#msg61059 ---
« Last Edit: August 31, 2009, 01:08:20 PM by nukpana »
Logged

Sven

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

It doesn't work as expected per the first post screenshots, but I raced through this...
Me too. Nothing cames out the DB.
I'll carry on.

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: previous article and next article links
« Reply #18 on: August 31, 2009, 12:53:11 PM »

Mod posted http://snewscms.com/forum/index.php?topic=8623.msg61059#msg61059

Completed.

Pretty simple really.  We grab the current page's id and category. Then, the language code goes into the query.  If one of the queries in the union fails (a.id = (1 - 1)), then nothing is noted instead of saying NEXT ARTICLE: NONE. - this is for usually the first or the last article in the category.  This only goes within the category. One query instead of the 5 for the original mod.
« Last Edit: August 31, 2009, 01:08:08 PM by nukpana »
Logged

mfaraklit

  • Newbie
  • *
  • Karma: 1
  • Posts: 20
Re: previous article and next article links
« Reply #19 on: September 18, 2012, 08:44:59 AM »

Hi,

In this mod, draft articles (not yet published) are shown too. So, in order to avoid this situation, you must write the "AND published = 1" end of the mysql query.

At the MySQL query rows (to the Armen's optimized code: http://snewscms.com/forum/index.php/topic,7393.msg55046.html#msg55046):
First query in the code:
Code: [Select]
$query = "SELECT id FROM ".db('prefix')."articles WHERE seftitle = '$articleSEF' AND position = 1 AND published = 1";
Second query in the code:
Code: [Select]
$query = "SELECT id,title,seftitle,category FROM ".db('prefix')."articles WHERE id < $articleId AND position = 1 AND published = 1 ORDER BY id DESC LIMIT 1";
Third query in the code:
Code: [Select]
$query = "SELECT id,title,seftitle,category FROM ".db('prefix')."articles WHERE id > $articleId AND position = 1 AND published = 1 ORDER BY id LIMIT 1";
Logged
Pages: 1 [2]