Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Help needed -- Getting recent articles from one specific category  (Read 6181 times)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal

I'm working on an sNews site where there's a big mix of static and dynamic content. The client's requests now means that I need to modify the menu_articles function so that it only gets recent articles from a specific category. I guess I could change the menu_articles for this particular site to look only in one hard coded category, but, then I thought what if..?

What if the client changes her mind?
What if she wants recent articles from more than one cat?
What if we make it truly modal, so that instead of calling in recent articles from all categories, we can add a variable $cat to let us specify one (or more?) categories to pull content from, instead of the generic 'all' cats?
Something like:
Quote
function menu_articles($start, $size, $cat1, $cat2, $catchall) {
Here's the pinch: I have absolutely no idea how to code that.  :rolleyes:
Anyone feel like lending a hand? I might be inclined to reward you for it, if it's at all possible. ;)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Help needed -- Getting recent articles from one specific category
« Reply #1 on: April 20, 2007, 11:07:47 pm »

ok ... //scratching head fervently// I think I get your drift.

1) [I copy 'published' line from sql] make new db field in categories:
Quote
show_new varchar(4) NOT NULL default 'YES',
2) Add the checkbox (3 new lines in Category form)
Quote
/*      $frm_shownew = $r['show_new'] == 'YES' ? 'ok' : ''; // when yes, show recent articles */
... and ...

//      $frm_shownew = 'ok';
... and ...

//   html_input('checkbox', 'show recent', 'show', 'YES', l('show_new'), '', '', '', '', $frm_shownew, '', '', '', '', '');
ok, no problem. free your mind. Free. Your. Mind.
Now for the fun part... ;)

(I'm still asking for help btw, if anyone else has a minute. Bob, I appreciate the input so far. If you have more ideas, don't keep them to yourself, ok? ;D)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Help needed -- Getting recent articles from one specific category
« Reply #2 on: April 20, 2007, 11:21:04 pm »

heh- you must've been writing it while I was writing mine. Thanks! I'll burrow down... ;)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Help needed -- Getting recent articles from one specific category
« Reply #3 on: April 21, 2007, 12:00:30 am »

Bob, I hope you know that while this may be everyday stuff for you, it would have taken me weeks (or more) to solve on my own. It works brilliantly. Let me know how much you want for the code (PM might be prudent? ;)) -- or do you have an Amazon wishlist or similar?

Cheers, mate!
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Help needed -- Getting recent articles from one specific category
« Reply #4 on: April 21, 2007, 05:26:10 am »

Bob the (MOD) Builder :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Michał Nowak

  • Newbie
  • *
  • Karma: 0
  • Posts: 11
    • http://www.nowakmichal.nazwa.pl
Help needed -- Getting recent articles from one specific category
« Reply #5 on: May 07, 2007, 12:49:06 pm »

Hi!
I've problem with 6th step, I don't know how to do this, can anyone help me?

STEP 6 - database - categories table
Quote
ALTER TABLE prefix_categories ADD `show_new` char(3) NOT NULL default 'NO'
I opened phpMyAdmin and went to my database to categories table and I don't know how to add this.
Logged
If you see a language mistake, do not hesitate to correct me. =)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Help needed -- Getting recent articles from one specific category
« Reply #6 on: May 07, 2007, 01:59:15 pm »

Go back one step to the database root, e.g without clicking "categories". Click on "SQL" and then paste the query in the frame at midpage. Remember to remove prefix_ if you're not using a prefix or chnaging it to your prefix if you are. Then click Go. That's all.
Logged