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.

Author Topic: A question about specific category articles.  (Read 2586 times)

bloop

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
A question about specific category articles.
« on: February 26, 2007, 03:22:34 am »

Hello ,
I am using sNEWS in my website , and i have approximately 10 categories.i show last articles in home page.But  at the top of my page , i want to show my news category also.Assume that i have music,news,software,hardware categories.On my main page i show the last articles of all these categories and also i want to show only last news articles above them.How can i do it ?
Thank you
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
A question about specific category articles.
« Reply #1 on: February 26, 2007, 03:50:39 am »

so, to clarify,
1) you want a place that shows only last news,
2) you want a place to show last of any except news

yes?

if so,
for 1) make new function that only selects category news (copy, rename and alter function menu_articles()) then add to index.php in relevant place.
for 2) alter function menu_articles() to omit news category articles
Logged
Of all the things I have lost, it is my mind that I miss the most.

bloop

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
A question about specific category articles.
« Reply #2 on: February 28, 2007, 11:28:28 am »

Could you please send me the mysql code that calls news in category ?I couldt do it because i dont know php  :(

 
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start, $size";

Is it be like this ?
$query = "SELECT * FROM ".db('prefix')."categories news WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start, $size";
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
A question about specific category articles.
« Reply #3 on: February 28, 2007, 01:25:27 pm »

Quote from: bloop
Could you please send me the mysql code that calls news in category ?I couldt do it because i dont know php  :(
Not quite.
... and php is going to be needed ...
so...

firstly, have you made a copy of menu_articles() and renamed it?
the following you need to paste just after the { of BOTH functions like so
Quote
function menu_articles($start, $size) {
   $cat_news = retrieve('id', 'categories', 'seftitle', 'news');
and
Quote
function menu_news_articles($start, $size) {
   $cat_news = retrieve('id', 'categories', 'seftitle', 'news');
replace news with any category seftitle of your choice.

then, alter the line you were playing with in both functions.
Firstly, the function that is to display  news only, make the line like this
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 AND category = $cat_news ORDER BY date DESC LIMIT $start, $size";
then the function that is to NOT EVER show news
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 AND category <> $cat_news ORDER BY date DESC LIMIT $start, $size";
.. and I think that will just about do it.


NOTE to MODERATORS .. into programming please....

[I have vague recollections of doing something similar before in one of the 1.5 pre-release/RC forums]
Logged
Of all the things I have lost, it is my mind that I miss the most.

bloop

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
A question about specific category articles.
« Reply #4 on: February 28, 2007, 05:25:40 pm »

Thank you very much phil , I did =) It shows only news cat.
Thank you  :)
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
A question about specific category articles.
« Reply #5 on: February 28, 2007, 11:41:06 pm »

no probs  :P
Logged
Of all the things I have lost, it is my mind that I miss the most.