Please login or register.

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

Author Topic: [MOD] Displaying X amount from specific category  (Read 6469 times)

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« on: January 22, 2006, 09:13:34 pm »

Hi.

I want to customise the home page a little, I will be having three columns.

One where the
is and all articles will be displayed, and two further columns.

At the moment, in the new_articles function (V1.4 beta) displays the three latest articles from any category, but I'd like the two extra columns to display a specific amount from a specific category.

How would I do this? I had a brief look at the php (im a complete noivce) to see if I could do this myself but I really do not know where to start!

Any advice appreciated! Thanks in advance.
Logged

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
[MOD] Displaying X amount from specific category
« Reply #1 on: January 22, 2006, 09:36:07 pm »

It's not that complicated, If I catch the time I could do that for you but it's basically this:

Copy the past_articles function and just change the query to this:

Code: [Select]

$query = "SELECT * FROM " .s('prefix'). "articles WHERE position = 1 AND published = 1 AND category = 4 ORDER BY id DESC LIMIT $ts, $tl";


Change category number to category you want...
Logged

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #2 on: January 22, 2006, 09:37:51 pm »

thats fantastic, I will have a play now, thanks Luka!
Logged

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
[MOD] Displaying X amount from specific category
« Reply #3 on: January 22, 2006, 09:44:04 pm »

I forgot to say that past_articles by default displays past articles from the category you're browsing so there could be some trouble with that. When you enter specific category you might end up with 2 functions displaying the same links.
Logged

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #4 on: January 22, 2006, 09:57:37 pm »

Heres what I did:

Copied the function as you said:

Code: [Select]
// PAST news ENTRIES
function past_news($ts, $tl) {
if (isset($_GET['category']) <> 0) { $category = $_GET['category']; } else { $category = 0; };
$query = "SELECT * FROM " .s('prefix'). "articles WHERE position = 1 AND published = 1 AND category = 6 ORDER BY id DESC LIMIT $ts, $tl"; $result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
$date = date(s('date_format'), strtotime($r['date']));
echo "

$r[title] ";
echo $date;
echo "

"; }
}

and added the following underneath "Past Entries" on index.php:

Code: [Select]

Past news:




and nothing happened, except I had a new "Past News" title in the left column

I then changed it to:

Code: [Select]

Past news:




and a few other combinations and only one of the last articles from that category displays. but it does work!

How would I make it display the three most recent, for example?
Logged

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
[MOD] Displaying X amount from specific category
« Reply #5 on: January 22, 2006, 09:59:44 pm »

To display most recent articles change DESC in the query to ASC  ;D
Logged

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #6 on: January 22, 2006, 10:15:04 pm »

Thanks Luka,

One more thing though!

Code: [Select]
   

What do the numbers mean? If I leave them like that, no articles are displayed, if I do just one (1) i get this;

Code: [Select]
Warning: Missing argument 2 for past_news() in /home/frantik1/public_html/test/snews.php on line 700

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/frantik1/public_html/test/snews.php on line 703

What am i doing completely wrong here?
Logged

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
[MOD] Displaying X amount from specific category
« Reply #7 on: January 22, 2006, 10:16:59 pm »

I'm not sure, try to change tl variables as they may have been user, however they should be erased when exiting function.

First number is to decide from which article to start and the second is how much of articles you want.

3,4 means start from the 3rd and display 4 articles.
Logged

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #8 on: January 22, 2006, 10:57:34 pm »

Done it!

changing DESC to ASC means first post at the top, but leaving it as DESC means most recent at the top.

Code: [Select]
   

This means to start from the first post, and display three articles.

Thanks so much Luka, finally figured it out!

I have not as yet found any iddues with 1.4, but I'll do more testing tomorrow.
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] Displaying X amount from specific category
« Reply #9 on: January 23, 2006, 01:50:31 pm »

Hehe, Id-dudes, sorry, TJ, have to laugh a bit... Is that a kind of identification police ? /jk - knows you mean issues... ;)
Logged
"It's only dead fish that goes with the flow... "
Updated

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #10 on: February 09, 2006, 12:50:19 pm »

Quote from: Patric
Hehe, Id-dudes, sorry, TJ, have to laugh a bit... Is that a kind of identification police ? /jk - knows you mean issues... ;)

lol, hate this keyboard!


One more thing, related to this..


I'd like the home page to display the five/ ten / 20 or whatever most recent posts from all categories, most recent first.

I know it currently shows the most recent topics, but it doesnt give a teaser, and I'd want to move this to the center of the page.

I tried modifying bits and bobs of the php but I got way in over my head and now have a headache! can anyone give m some starter points on how to do this?
Logged

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #11 on: March 31, 2006, 11:13:45 am »

Quote
One more thing, related to this..


I'd like the home page to display the five/ ten / 20 or whatever most recent posts from all categories, most recent first.

I know it currently shows the most recent topics, but it doesnt give a teaser, and I'd want to move this to the center of the page.

I tried modifying bits and bobs of the php but I got way in over my head and now have a headache! can anyone give m some starter points on how to do this?

Is this even possible?

Say you have the title and first 200 characters of the last five posts in all categories with a date, the category its posted in and a read more link.
Logged

bryn

  • Hero Member
  • *****
  • Karma: 2
  • Posts: 934
    • http://www.cssugly.com
[MOD] Displaying X amount from specific category
« Reply #12 on: April 01, 2006, 08:33:29 am »

this would need one of them coding guru people Tj..but it certainly would be a handy mod ;D
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #13 on: April 03, 2006, 04:07:54 pm »

Quote from: bryn
this would need one of them coding guru people Tj..but it certainly would be a handy mod ;D

It certainly would Bryn,

I just tried to play about with the "" but couldn't get it to do what I need.

Would be cool so that it shows the title, first 200 characters, and a read more link, on the home page only, how its done is beyond me - it makes my brain hurt!
Logged

Tjobbe

  • Full Member
  • ***
  • Karma: 0
  • Posts: 112
    • http://www.farstyle.com
[MOD] Displaying X amount from specific category
« Reply #14 on: April 18, 2006, 09:43:55 pm »

I think something similar to this would/ could work, I've tried it, but it doesnt so it needs some sweet loving from a php guru!

Code: [Select]

new_articles(5)

Basicly, I want it to display the latest 5 articles from all cetegories if it is the home page. possible?
Logged
Pages: [1] 2