 |
 |
 |
 |
 |
| Author |
Message |
sikopat
Joined: 06 Oct 2007 Posts: 12
|
|
How to display all news item of a category |
|
Hi all,
I am trying to display all the news of a category when a user leaves the keyword field blank and selects a certain category. Let say, the latter, leaves the keyword field empty and then selects the game category, once he hits the search button, I would like to have all the news belonging to that category come up as results.
Anyone has any clue how to achieve that?
Thanks in advance.
|
|
| Tue May 20, 2008 2:32 pm |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
Try this:
Open search.php and find this:
 |  | if ($search){
$template = 'Search';
include $cutepath.'/show_news.php';
} |
add below:
 |  | elseif ($search == '' and $category){
$template = 'Search';
include $cutepath.'/show_news.php';
} |
|
|
| Wed May 21, 2008 7:43 pm |
|
 |
sikopat
Joined: 06 Oct 2007 Posts: 12
|
|
|
|
Thanks FI-DD, it worked
|
|
| Thu May 22, 2008 8:48 am |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1943 Location: US |
|
|
|
Mine looks like this:
 |  | if ($search){
ob_start();
$template = 'Search';
include $cutepath.'/show_news.php';
$show_news = ob_get_contents();
ob_get_clean();
$show_news = str_replace("?search_boolean=or", "", $show_news);
$show_news = str_replace("?search_boolean=and", "", $show_news);
echo $show_news;
} |
So, while using your boolean search would I be correct to assume that this is what I would want to do to modify this in working condition?
 |  | if ($search){
ob_start();
$template = 'Search';
include $cutepath.'/show_news.php';
elseif ($search == '' and $category){
$template = 'Search';
include $cutepath.'/show_news.php';
$show_news = ob_get_contents();
ob_get_clean();
$show_news = str_replace("?search_boolean=or", "", $show_news);
$show_news = str_replace("?search_boolean=and", "", $show_news);
echo $show_news;
} |
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm
Last edited by scottdallas on Fri May 30, 2008 12:11 am; edited 1 time in total |
|
| Sun May 25, 2008 5:38 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
The easiest would be this:
 |  | if ($search){
ob_start();
$template = 'Search';
include $cutepath.'/show_news.php';
$show_news = ob_get_contents();
ob_get_clean();
$show_news = str_replace("?search_boolean=or", "", $show_news);
$show_news = str_replace("?search_boolean=and", "", $show_news);
echo $show_news;
}
elseif ($search == '' and $category){
ob_start();
$template = 'Search';
include $cutepath.'/show_news.php';
$show_news = ob_get_contents();
ob_get_clean();
$show_news = str_replace("?search_boolean=or", "", $show_news);
$show_news = str_replace("?search_boolean=and", "", $show_news);
echo $show_news;
} |
|
|
| Thu May 29, 2008 6:19 pm |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1943 Location: US |
|
|
|
Perfect, thanks FI-DD
How come when I select 'All' it doesn't work though? It only works when I specify a specific category from the drop-down with a blank search field. Any idea?
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Fri May 30, 2008 12:22 am |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
Because there's no category assigned to "All" and the script needs a category.
Try changing this:
 |  | elseif ($search == '' and $category){ |
to this:
 |  | elseif ($search == ''){ |
|
|
| Fri Jun 06, 2008 2:24 pm |
|
 |
|
|
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 You cannot attach files in this forum You can download files in this forum
|
|
 |
 |
 |
|