Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
How to display all news item of a category

 
Reply to topic    Forum Index » Help View previous topic
View next topic
How to display all news item of a category
Author Message
sikopat



Joined: 06 Oct 2007
Posts: 12

Post How to display all news item of a category Reply with quote
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 View user's profile Send private message
Guest








Please login to hide the ads.

FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
Try this:

Open search.php and find this:
Code:
if ($search){
   $template = 'Search';
   include $cutepath.'/show_news.php';
}


add below:
Code:
elseif ($search == '' and $category){
   $template = 'Search';
   include $cutepath.'/show_news.php';
}

Wed May 21, 2008 7:43 pm View user's profile Send private message
sikopat



Joined: 06 Oct 2007
Posts: 12

Post Reply with quote
Thanks FI-DD, it worked
Thu May 22, 2008 8:48 am View user's profile Send private message
scottdallas



Joined: 04 May 2006
Posts: 1943
Location: US

Post Reply with quote
Mine looks like this:

Code:
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?

Code:
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 Smile
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 View user's profile Send private message Visit poster's website AIM Address
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
The easiest would be this:
Code:
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 View user's profile Send private message
scottdallas



Joined: 04 May 2006
Posts: 1943
Location: US

Post Reply with quote
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 Smile
last update: 07-22-08: 8:30 pm
Fri May 30, 2008 12:22 am View user's profile Send private message Visit poster's website AIM Address
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
Because there's no category assigned to "All" and the script needs a category.

Try changing this:
Code:
elseif ($search == '' and $category){


to this:
Code:
elseif ($search == ''){

Fri Jun 06, 2008 2:24 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Help All times are GMT + 1 Hour
Page 1 of 1

 
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
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.