boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Index by category
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    boardom Forum Index -> How to ?
View previous topic :: View next topic  
Author Message
vermifuge



Joined: 14 Jan 2003
Posts: 12

PostPosted: Tue Jan 14, 2003 9:57 am    Post subject: Index by category Reply with quote

Is it possible to have the front page display the entries by a catigoty rather then by date or etc?

Actualy, i think this would make a great feature request too.

any how is there any way to change this via the code?
Back to top
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1019
Location: Oregon

PostPosted: Tue Jan 14, 2003 10:01 pm    Post subject: Reply with quote

That's rather easy to accomplish. In blog.header.php, locate:

Code:

$orderby='date '.$order;


Then change the "date" to "category". Also, don't forget the single space after the word; i.e., "category ".
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
vermifuge



Joined: 14 Jan 2003
Posts: 12

PostPosted: Tue Jan 14, 2003 10:06 pm    Post subject: Reply with quote

Wow, that was way to easy! thanks. i had been looking at that code for 10 hours yesterday i just could not figure it out =P.

Is it possible to display only one catagory? say i want the index only to display CAT ID 1
Back to top
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1019
Location: Oregon

PostPosted: Tue Jan 14, 2003 10:22 pm    Post subject: Reply with quote

On top of your template, whether it be b2.php or index.php, put "$cat=#" at the beginning right after inclusion of blog.header.php file. You have to replace "#" to the number of the category you want to display, of course.
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
vermifuge



Joined: 14 Jan 2003
Posts: 12

PostPosted: Tue Jan 14, 2003 11:38 pm    Post subject: Reply with quote

hmm i put this in my index and b2 files with no luck. it looked like this.

<?php /* Don't remove this line, it calls the b2 function files ! */ $blog=2; include ("blog.header.php"); $cat=1; ?>

i did it like this too

<?php /* Don't remove this line, it calls the b2 function files ! */ $blog=2; include ("blog.header.php"); $cat=1 ?>

I did get it to wok by puting it here in place of the blog

<?php /* Don't remove this line, it calls the b2 function files ! */ $cat=1; include ("blog.header.php"); ?>

but if i did it like that, all the category pages would display the one catigory specified in the above line.

any ideas?
Back to top
View user's profile Send private message
dtdgoomba



Joined: 05 Aug 2002
Posts: 179
Location: Cambridge, MA

PostPosted: Wed Jan 15, 2003 12:00 am    Post subject: Reply with quote

try putting all your variables before the include blog header. i think you need to first set those so that when blog.header is called, it uses them. If you put it after, it probably ignores it

$blog=2; include ("blog.header.php"); $cat=1;

so $blog=2; $cat=1; include etc
Back to top
View user's profile Send private message Visit poster's website
vermifuge



Joined: 14 Jan 2003
Posts: 12

PostPosted: Wed Jan 15, 2003 12:24 am    Post subject: Reply with quote

dtdgoomba wrote:
try putting all your variables before the include blog header. i think you need to first set those so that when blog.header is called, it uses them. If you put it after, it probably ignores it

$blog=2; include ("blog.header.php"); $cat=1;

so $blog=2; $cat=1; include etc


This will work. for that one page.

<?php /* Don't remove this line, it calls the b2 function files ! */ $blog=2; $cat=1; include ("blog.header.php"); ?>

So now when i go to my url or url/index.php it will show the cat id i stated. but now

index.php?cat=2
index.php?cat=3
index.php?cat=4

and so on all how the cat 1 content.
Back to top
View user's profile Send private message
macshack



Joined: 17 Jul 2002
Posts: 1204
Location: Phoenix, Az

PostPosted: Wed Jan 15, 2003 4:29 am    Post subject: Reply with quote

Hi,

Ok, if you put this code before the call to blog.header.php, then $cat will be either what you preset or what was in the url.
Code:

$cat = 1;   // <<<< preset to cat X
if (empty($HTTP_POST_VARS['cat'])) {
    if (!empty($HTTP_GET_VARS['cat'])) {
        $cat = $HTTP_GET_VARS['cat'];
    }
} else {
    $cat = $HTTP_POST_VARS['cat'];
}


Hope this helps,
michael e

[after thought]
This is only going to work if you are using the "normal" query string delimiters: '?' '&'.
If your using the '/' experimental code, the above will need to be changed.
michael e
Back to top
View user's profile Send private message Send e-mail
vermifuge



Joined: 14 Jan 2003
Posts: 12

PostPosted: Wed Jan 15, 2003 5:32 am    Post subject: Reply with quote

macshack wrote:
Hi,

Ok, if you put this code before the call to blog.header.php, then $cat will be either what you preset or what was in the url.
Code:

$cat = 1;   // <<<< preset to cat X
if (empty($HTTP_POST_VARS['cat'])) {
    if (!empty($HTTP_GET_VARS['cat'])) {
        $cat = $HTTP_GET_VARS['cat'];
    }
} else {
    $cat = $HTTP_POST_VARS['cat'];
}


Hope this helps,
michael e

[after thought]
This is only going to work if you are using the "normal" query string delimiters: '?' '&'.
If your using the '/' experimental code, the above will need to be changed.
michael e


HOT DAMN! that worked. thanks so much
Back to top
View user's profile Send private message
macshack



Joined: 17 Jul 2002
Posts: 1204
Location: Phoenix, Az

PostPosted: Wed Jan 15, 2003 6:29 am    Post subject: Reply with quote

Your welcome. Very Happy
Back to top
View user's profile Send private message Send e-mail
timtucker



Joined: 23 Jan 2003
Posts: 4

PostPosted: Mon Jan 27, 2003 6:30 pm    Post subject: You rock... Reply with quote

This is the most useful bit of code I have found so far.
Back to top
View user's profile Send private message
tariq



Joined: 29 Jan 2003
Posts: 1

PostPosted: Sat Feb 01, 2003 10:34 pm    Post subject: limiting # of articles Reply with quote

I used the code and it works great. but now there's a new problem: I can't set any limits for the number of articles shown. Is this doable?
Back to top
View user's profile Send private message Visit poster's website
Cyberian75



Joined: 26 Sep 2002
Posts: 1019
Location: Oregon

PostPosted: Sat Feb 01, 2003 10:46 pm    Post subject: Reply with quote

If you set your "Show" option to "posts paged," you won't have that problem.

By the way, thanks for the code, marshack. Smile
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
redg8r



Joined: 11 Mar 2003
Posts: 7

PostPosted: Wed Mar 12, 2003 11:41 pm    Post subject: Reply with quote

Nice work

Can we take it up a notch & show lates post in every category, nested in a table?

I can do the template, just fuzzy on the DB query

I'm wanting to use the blog as a newsletter & being able to show the latest post in each category, from one central page would rock.

any ideas?

Thanks
Back to top
View user's profile Send private message
celia



Joined: 06 Apr 2003
Posts: 2

PostPosted: Sun Apr 06, 2003 8:22 pm    Post subject: Reply with quote

This post seems dead but anyway...
There is a problem with this hack, see this
http://tidakada.com/board/viewtopic.php?p=13038
If you have any idea of how to fix it, then I'll be glad if you help me Very Happy
Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> How to ? All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group