Maian Script World on Facebook Maian Script World on Twitter Maian Script World - Latest News Maian Script World on YouTube Maian Script World on LinkedIn


Please Read

You are required to register before you can post. This is via a custom verification system. Please post any problems you are encountering here and I`ll do my best to respond as soon as I can. Please note that a reply WILL be posted to all queries, so do not double post. There are no guarantees when a reply will appear but I do my best to answer all within 3/4 days max. Bumping topics won`t make the slightest difference.

IMPORTANT: Posts in English ONLY please, thank you! Any other languages will be ignored and your message deleted.
SEARCH: Use the search option to see if your question has been answered on the forum before. Or check the relevant script docs.
CUSTOMER: If you have purchased a commercial version of any of my software, using the contact option at the licence centre ensures a faster response.
AUTO DELETION: Accounts older than 5 days, with no posts or topics, are automatically deleted. Only register if you are thinking of posting.
PRIVATE MESSAGES: Private messages are currently disabled.
LINKS: Any links posted are 'NOFOLLOW' and will not be picked up by search engines.

You are not logged in.

#1 21-02-2011 10:33:19

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

limit the results on the archive page

How can I limit the archive page to show the latest 5 blog posts instead of all blogs?

Offline

#2 21-02-2011 22:46:46

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,117

Re: limit the results on the archive page

In the main index.php file around line 529 you`ll see:

$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs
                            ".($cmd=='archive' ?
                            'WHERE archiveMonth = \''.$a_month.'\' && archiveYear = \''.$a_year.'\'' :
                            '')."
                            ORDER BY title
                            LIMIT $limitvalue,$SETTINGS->total") or die(mysql_error());

Change to:

$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs
                            ".($cmd=='archive' ?
                            'WHERE archiveMonth = \''.$a_month.'\' && archiveYear = \''.$a_year.'\'' :
                            '')."
                            ORDER BY id
                            LIMIT 5") or die(mysql_error());

You`ll probably want to remove the page numbers as well.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#3 21-02-2011 23:45:13

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

Re: limit the results on the archive page

How about limiting the results to the most current dates and not in alphabetical order? Thanks again.

Offline

#4 22-02-2011 06:42:35

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,117

Re: limit the results on the archive page

When you say, most current dates, what range are you looking for? Today? Last week? Month?


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#5 22-02-2011 06:49:28

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

Re: limit the results on the archive page

current month I suppose?  I would like to show the five most current blogs written.

Offline

#6 22-02-2011 13:00:36

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,117

Re: limit the results on the archive page

$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs ORDER BY id LIMIT 5") or die(mysql_error());


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#7 22-02-2011 13:16:08

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

Re: limit the results on the archive page

Thanks again. Works great. For those who wish to have the list in descending order, I've figured out how to edit the code to this.

$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs ORDER BY id DESC LIMIT 5") or die(mysql_error());

Last edited by duceduc (22-02-2011 13:16:31)

Offline

#8 23-02-2011 08:12:50

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,117

Re: limit the results on the archive page

Yes, thats correct. smile


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#9 10-06-2011 18:45:57

cowgirlmodel
Members
Registered: 28-09-2009
Posts: 8

Re: limit the results on the archive page

Thank you so much for this post! I did not want my archive limited; but I did want it to sort posts by date in descending order; not alphabetically. This was a quick fix: ORDER BY id DESC


// Second query returns the data with limit clause for pagination..
   $q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs
                            ".($cmd=='archive' ?
                            'WHERE archiveMonth = \''.$a_month.'\' && archiveYear = \''.$a_year.'\'' :
                            '')."
                            ORDER BY id DESC
                            LIMIT $limitvalue,$SETTINGS->total") or die(mysql_error());


I love this blog.

Offline

#10 11-06-2011 05:14:28

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,117

Re: limit the results on the archive page

Excellent, glad you like it. smile


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

Board footer

2Checkout.com is an authorized reseller of goods and services provided by Maian Script World.© 2003-2013 David Ian Bennett. All Rights Reserved | Forum: FluxBB

Privacy Policy | Refund Policy