View previous topic :: View next topic |
Author |
Message |
vermifuge
Joined: 14 Jan 2003 Posts: 12
|
Posted: Tue Jan 14, 2003 9:57 am Post subject: Index by category |
|
|
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 |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1019 Location: Oregon
|
Posted: Tue Jan 14, 2003 10:01 pm Post subject: |
|
|
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 |
|
 |
vermifuge
Joined: 14 Jan 2003 Posts: 12
|
Posted: Tue Jan 14, 2003 10:06 pm Post subject: |
|
|
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 |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1019 Location: Oregon
|
Posted: Tue Jan 14, 2003 10:22 pm Post subject: |
|
|
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 |
|
 |
vermifuge
Joined: 14 Jan 2003 Posts: 12
|
Posted: Tue Jan 14, 2003 11:38 pm Post subject: |
|
|
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 |
|
 |
dtdgoomba
Joined: 05 Aug 2002 Posts: 179 Location: Cambridge, MA
|
Posted: Wed Jan 15, 2003 12:00 am Post subject: |
|
|
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 |
|
 |
vermifuge
Joined: 14 Jan 2003 Posts: 12
|
Posted: Wed Jan 15, 2003 12:24 am Post subject: |
|
|
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 |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Wed Jan 15, 2003 4:29 am Post subject: |
|
|
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 |
|
 |
vermifuge
Joined: 14 Jan 2003 Posts: 12
|
Posted: Wed Jan 15, 2003 5:32 am Post subject: |
|
|
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 |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Wed Jan 15, 2003 6:29 am Post subject: |
|
|
Your welcome.  |
|
Back to top |
|
 |
timtucker
Joined: 23 Jan 2003 Posts: 4
|
Posted: Mon Jan 27, 2003 6:30 pm Post subject: You rock... |
|
|
This is the most useful bit of code I have found so far. |
|
Back to top |
|
 |
tariq
Joined: 29 Jan 2003 Posts: 1
|
Posted: Sat Feb 01, 2003 10:34 pm Post subject: limiting # of articles |
|
|
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 |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1019 Location: Oregon
|
Posted: Sat Feb 01, 2003 10:46 pm Post subject: |
|
|
If you set your "Show" option to "posts paged," you won't have that problem.
By the way, thanks for the code, marshack.  _________________ Michael P. |
|
Back to top |
|
 |
redg8r
Joined: 11 Mar 2003 Posts: 7
|
Posted: Wed Mar 12, 2003 11:41 pm Post subject: |
|
|
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 |
|
 |
celia
Joined: 06 Apr 2003 Posts: 2
|
Posted: Sun Apr 06, 2003 8:22 pm Post subject: |
|
|
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
Thanks! |
|
Back to top |
|
 |
|