Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: [1] 2

Author Topic: [MOD] Article sorting v0.1b (sNews 1.5RC1)  (Read 16475 times)

celebro

  • Guest
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« on: October 06, 2006, 08:57:08 PM »

=========================================
[MOD] ARTICLE SORTING 0.1b - sNews 1.5.26
=========================================

Description:
Ability to display Articles in any chosen order. This is still being worked on but it works so far. So I figured I post it thanks to mika for showing  me the light. All these modifications are done on a fresh vanilla install. This has been written from the top down. So as you add code, the line  numbers reference the modified version thats why I include the original format followed by the  modified version. I will make further modifications to this once the bugs have been cleaned out and this has been cleaned up a bit.



Usage:
Assign a order value when creating the article 0-X.  0 Being the first article 1,2,3 etc.. follows the order. Duplicate entries will be displayed in the order created. *Hint*: Use 0 for static/fixed articles.

Todo/Modify:
- Ability to turn this on or off within a language
  variable, defaulting to default 'id ASC'
  eg: l['artorder_switch'] = 'ON'; // chose ON or OFF



Warning:
**********************************************************************
BACKUP YOUR SNEWS.PHP AND DATABASE!! THIS HAS NOT BEEN FULLY TESTED.
IF IT DELETES YOUR DATA YOUR OUT OF LUCK. DO IT NOW!
**********************************************************************


Modifications:

1. We need to add an extra field to the articles table to hold our sort order. I recommend doing this in phpMyAdmin. Or if your trying it out on a fresh install use this for the articles table in your MySQL database.

Code: [Select]
CREATE TABLE articles (
id int(11) primary key auto_increment,
title varchar(100) default NULL,
seftitle varchar(100) default NULL,
`text` longtext,
`date` datetime default NULL,
category int(8) NOT NULL default '0',
position int(6) default NULL,
displaytitle char(3) NOT NULL default 'YES',
displayinfo char(3) NOT NULL default 'YES',
commentable varchar(5) NOT NULL default '',
published int(3) NOT NULL default '1',
description_meta varchar(100) default NULL,
keywords_meta varchar(100) default NULL,
artorder int(11)
);
2. // LANGUAGE VARIABLES line 41:

Code: [Select]
$l['cat_listSEF'] = 'home,archives,contact,sitemap,rss,gallery,login,administration,add_category,add_article,article_new,side_new,page_new,categories,articles,extra_contents,pages,settings,files,logout,artorder'; //SEF links of the hardcoded categoriesreplace with:
Code: [Select]
$l['cat_listSEF'] = 'home,archives,contact,sitemap,rss,gallery,login,administration,add_category,add_article,article_new,side_new,page_new,categories,articles,extra_contents,pages,settings,files,logout,artorder'; //SEF links of the hardcoded categoriesnote: not sure if this was needed or not but it wouldn't hurt I suppose.

3. // DISPLAY PAGES line 337:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id";replace with:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY artorder ASC";4. // EXTRA CONTENT line 355:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE SUBSTRING(position, 1, 1) = '2' AND published = 1 ORDER BY id DESC";replace with:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE SUBSTRING(position, 1, 1) = '2' AND published = 1 ORDER BY artorder ASC";5. // CENTER line 440:
Code: [Select]
$query_articles .= " AND position <> 3 ORDER BY date DESC";replace with:
Code: [Select]
$query_articles .= " AND position <> 3 ORDER BY artorder ASC";6. // CENTER line 642:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 AND published = '1' ORDER BY id";replace with:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 AND published = '1' ORDER BY artorder ASC";7. // MENU ARTICLES line 720:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY id DESC LIMIT $start, $size";\replace with:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY artorder ASC LIMIT $start, $size";8. // ARTICLES FORM line 1115:
Code: [Select]
$frm_publish = $r['published'] == 1 ? 'ok' : '';add below:
Code: [Select]
$artorder = $r['artorder'];9. // ARTICLES FORM line 1134:
Code: [Select]
$frm_display_info = ($contents == 'side_new') ? '' : 'ok';add below:
Code: [Select]
$artorder = $r['artorder'];* Note: I am not 100% sure this is actual correct syntax for how it should be referenced.
10. // ARTICLES FORM line 1160:
Code: [Select]
echo '

';
add below:
Code: [Select]
echo '

';
html_input('text', 'artorder', 'ao', $artorder, 'Article Order', 'style_me', '', '', '', '', '', '', '', '', '');
echo '

';
11. // ARTICLES FORM line 1189:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id ASC";replace with:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY artorder ASC";12. // ARTICLES - ADMIN LIST line 1249 [optional]:
If you want the Articles listed in the Admin panel to be ordered as you requested
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles $subquery ORDER BY date DESC";replace with:
Code: [Select]
$query = "SELECT * FROM ".db('prefix')."articles $subquery ORDER BY artorder ASC";13. /*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/ line 1319:
Code: [Select]
$date = date('Y-m-d H:i:s');add below:
Code: [Select]
$artorder = $_POST['artorder'];14. /*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/ line 1350:
Code: [Select]
$article_limit = $_POST['article_limit'];add below:
Code: [Select]
$artorder = $_POST['artorder'];15. /*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/ line 1477:
Code: [Select]
$query = "INSERT INTO ".db('prefix')."articles(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta')";replace with:
Code: [Select]
$query = "INSERT INTO ".db('prefix')."articles(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta, artorder) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta', $artorder)";16. /*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/ line 1519:
Code: [Select]
mysql_query($query." keywords_meta='$keywords_meta' ".$query_end);add below:
Code: [Select]
mysql_query($query." artorder='$artorder' ".$query_end);
Logged

celebro

  • Guest
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #1 on: October 08, 2006, 05:07:23 PM »

Anyone given this a go? Interested in feedback and how well this has gone with any other modifications anyone has done to their snews.php.
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #2 on: October 08, 2006, 05:20:03 PM »

I must say that this looks really nice, Cel-man. I haven't tested it, nor will I test this or anything else modwise until the stable release is out... Call me lazy, but I wanna do my own redesign to celebrate the birth of version 1.5 before I do anything else... But then... then, I'm really gonna pimp my install ;)
Logged
"It's only dead fish that goes with the flow... "
Updated

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #3 on: October 08, 2006, 06:40:09 PM »

I am doing the same as Patric - waiting for the stable release before working on mods and addons for it. Once the stable release has arrived, I will certainly test this one - for sure. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

celebro

  • Guest
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #4 on: October 08, 2006, 11:12:28 PM »

:) Cool, I guess I will wait and see maybe this gets added in.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #5 on: October 09, 2006, 12:53:23 AM »

Quote from: celebro
:) Cool, I guess I will wait and see maybe this gets added in.
I don't think it will get added in to the next release... as Luka and Mika are dedicated to keeping the size of the snews.php file to less than 100KB in size... that is their constant target. Considering they really re-worked the code to quite a high level of efficiencly in 1.5 over 1.4... and added significant flexibility to the system, I have a feeling there is very little head-room for more rationalization in snews.php.

But - again, it WOULD be nice to have this ADDED IN to the current revision, that is for sure. Let's hope Luka and Mika agree. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #6 on: October 09, 2006, 01:13:07 AM »

LOL, that 100Kb limit has already been explained.
I don't think that this mod will be included in RC2 but in stable release... perhaps... maybe... I dunno... okay, I'm convinced (hopefully not convicted by the beer keeper. again :D )
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

celebro

  • Guest
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #7 on: October 09, 2006, 02:41:28 AM »

Quote from: keyrocks
Quote from: celebro
:) Cool, I guess I will wait and see maybe this gets added in.
I don't think it will get added in to the next release... as Luka and Mika are dedicated to keeping the size of the snews.php file to less than 100KB in size... that is their constant target. Considering they really re-worked the code to quite a high level of efficiencly in 1.5 over 1.4... and added significant flexibility to the system, I have a feeling there is very little head-room for more rationalization in snews.php.

But - again, it WOULD be nice to have this ADDED IN to the current revision, that is for sure. Let's hope Luka and Mika agree. :)
This is not technically an addition this is a rework of the current code (replaced lines), at most 5 lines are added extra which are also very minimal and necessary only to add a new Text field to the articles section.

Quote from: mika
OL, that 100Kb limit has already been explained.
I don't think that this mod will be included in RC2 but in stable release... perhaps... maybe... I dunno... okay, I'm convinced (hopefully not convicted by the beer keeper. again  )
That's cool if not this modification I hope this is added into sNews (stable).. can you toss an old dog some kind of ETA on RC2/BETA2 heh? Although I believe most of the bugs that have been found have had a solution and been moded/fixed so how significant is RC2 actually going to be? Are there other planned features additions?
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #8 on: October 09, 2006, 07:44:41 AM »

optimistic version:
as soon as I finish changelog ;)

the other version:
both Luka & I have to finish our college duties for this term first (exams etc... :( )
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #9 on: October 09, 2006, 02:44:44 PM »

Quote from: mika
both Luka & I have to finish our college duties for this term first (exams etc... :( )
I didn't realize you and Luka were still in the 'formal' education mode... that makes me feel even more ancient age-wise. My last college days were about 35 years ago, and a short 4-week stint in university (over 2 years, 1990-91) with several essays spread in between. You are wise to keep your education a top priority while you are young, as life... kids, mortgages, car payments and college educations... will get in the way once you get started on that path. :) What is your major (and minor) subject(s)?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #10 on: October 09, 2006, 03:23:21 PM »

Whuaaaa, Key's... I'm currently investigating the possibilities to actually go to "school" again... newly becoming 40 ;) I feel alive, re-youth'ed if one may say so :lol:. Only hope I get in at a suiteable "program"...

Cross your fingers for me ;)
Logged
"It's only dead fish that goes with the flow... "
Updated

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #11 on: October 09, 2006, 03:29:54 PM »

my major is computer science, and minor are several IT economy courses
Luka has telecommunication as his major

my "formal" education is over, however this is the other way of studying - steady job along with afternoon classes at the local university (I don't know how do you call it over there, but here I have an extraordinary student status*)

[couple of days ago I've had an english language exam - 45 minutes of pure torture, but after that (graded with a B, hehe) I've realized that my major foreign language has been improved significantly, thx to this forum and all of you, guys'n'gals :) ]

______________
* our department of science and education fully supports students only if they're under 25 and unemployed...I obviously don't fit in those rules :| so I'm forced to finance it on my own
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #12 on: October 09, 2006, 05:27:19 PM »

Quote from: mika
1. my "formal" education is over, however this is the other way of studying - steady job along with afternoon classes at the local university (I don't know how do you call it over there, but here I have an extraordinary student status*)

2. Couple of days ago I've had an english language exam - 45 minutes of pure torture, but after that (graded with a B, hehe)

3. Our department of science and education fully supports students only if they're under 25 and unemployed...I obviously don't fit in those rules :| so I'm forced to finance it on my own
1. In Canada - it's just called "Adult Student".
2. You are doing very well with English - congratulations!
3. In Ontario, Canada, primary (grades 1 to 8) and secondary (grades 9 to 12) is fully government-funded. College and University... the student and/or parents must pay tuition, books and resources, and... if attending college or university in another town or city... the cost of "room and board". This can cost up to $20,000 per year and more. New students can get a "Student Loan" from the provincial government at low or no interest that must be paid back. Adult students are on their own but can get some support if they are unemployed for a long time.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

heathrowintl

  • Newbie
  • *
  • Karma: 0
  • Posts: 25
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #13 on: October 10, 2006, 04:49:44 AM »

well celebro...i am quite impressed that you have answered by question and will definitely test it out/give it a go...and give you some feedback.

thanks again
Logged

heathrowintl

  • Newbie
  • *
  • Karma: 0
  • Posts: 25
[MOD] Article sorting v0.1b (sNews 1.5RC1)
« Reply #14 on: October 10, 2006, 05:24:00 AM »

notes while implementing...
change 7 which is on 740...for me was 720

perhaps i misunderstood what the mod would achieve...but i had 8 pages of articles and the very first one i wrote became the newest article...and the very most recentest article was at the bottom of the last page...never the less...the reason i wanted the mod for repositioning the extra content...but editing the article order had no effect...

the implementation in itself went fine and the instructions were very good! (they are a pain to write!) any ideas...sorry if this i not useful
Logged
Pages: [1] 2