Search just one category or section
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
-
- Joomla! Apprentice
- Posts: 15
- Joined: Thu Dec 13, 2007 9:20 pm
Search just one category or section
Hi there,
I have searched and searched the forums here, and there appears to be no solution for the problem I'm having.
I need to provide visitors to our site with the option to either search within one section/category AND/OR search the whole site. I have one section of our site that needs it's own separate search feature, but I' don't want to abandon the ability to search the entire site from other sections' pages.
Content Search Extendedhttp://extensions.joomla.org/component/ ... Itemid,35/ is the only plugin I can find that does anything like this, but it is an either/or proposition - once you restrict the search to a specific section, you have no way to search the entire site (or vice-versa).
Is there a solution to this conundrum?
Thanks!
I have searched and searched the forums here, and there appears to be no solution for the problem I'm having.
I need to provide visitors to our site with the option to either search within one section/category AND/OR search the whole site. I have one section of our site that needs it's own separate search feature, but I' don't want to abandon the ability to search the entire site from other sections' pages.
Content Search Extendedhttp://extensions.joomla.org/component/ ... Itemid,35/ is the only plugin I can find that does anything like this, but it is an either/or proposition - once you restrict the search to a specific section, you have no way to search the entire site (or vice-versa).
Is there a solution to this conundrum?
Thanks!
-
- Joomla! Intern
- Posts: 52
- Joined: Tue Apr 17, 2007 2:11 pm
Re: Search just one category or section
I have a similar need for this...
has anyone figured out a way to do it?
has anyone figured out a way to do it?
-
- Joomla! Apprentice
- Posts: 15
- Joined: Thu Dec 13, 2007 9:20 pm
Re: Search just one category or section
I stall haven't found a solution for this - seems like there should be a canned solution for this, no?
*bump*
*bump*
-
- Joomla! Apprentice
- Posts: 15
- Joined: Thu Dec 13, 2007 9:20 pm
Re: Search just one category or section
Nobody has any ideas about this?
Really?
It doesn't seem like it'd be that unusual for someone to want this...am I the only one?
Really?
It doesn't seem like it'd be that unusual for someone to want this...am I the only one?
-
- Joomla! Apprentice
- Posts: 26
- Joined: Fri Sep 28, 2007 10:47 am
Re: Search just one category or section
I also need to do this. Did you ever find a solution to this? I'm amazed nobody has replied - looks like the quietest thread in Joomla!
Gary Brindley
QLUE
http://www.qlue.co.uk
If you can keep your head when people all around you are losing theirs then maybe you've misunderstood the situation.
QLUE
http://www.qlue.co.uk
If you can keep your head when people all around you are losing theirs then maybe you've misunderstood the situation.
-
- Joomla! Apprentice
- Posts: 15
- Joined: Thu Dec 13, 2007 9:20 pm
Re: Search just one category or section
I didn't find a solution to this. In fact, since I moved to PHP5 on our server the search feature doesn't work at all.
Go Joomla!
Go Joomla!
-
- Joomla! Intern
- Posts: 60
- Joined: Thu Dec 13, 2007 3:59 pm
Re: Search just one category or section
I'd like help with doing this too.
-
- Joomla! Apprentice
- Posts: 11
- Joined: Wed May 28, 2008 1:49 am
Re: Search just one category or section
I have a similar need? Anyone have any ideas how to go about it. Maybe we need to write it ourselves? Start with current seach component?
Thanks,
Maciej
Thanks,
Maciej
-
- Joomla! Intern
- Posts: 60
- Joined: Thu Dec 13, 2007 3:59 pm
Re: Search just one category or section
Search feature works okay for me on php5. I just wish you could type in more than 20 characters.
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Just started using Joomla and ran into this problem. I'm surprised it's not a feature of the built in search component.
Here's my solution - would like to hear ideas for something more elegant:
1. add a section id parameter to the search module (mod_search.xml)
2. pass section id to search component via post (mod_search/tmpl/default.php)
3. add section id to model parameters from component controller (com_search/controller.php)
4. add section_id parameter to setSearch method in model and add to constructor call (com_search/models/search.php)
5. add section_id to search plugin and call via dispatcher in model search->getData method (plugins/search/content.php, com_search/models/search.php)
and
6. add section_id conditionally to article search query and return results (plugins/search/content.php)
and, right after the article query,
hth
Here's my solution - would like to hear ideas for something more elegant:
1. add a section id parameter to the search module (mod_search.xml)
Code: Select all
<param name="section_search_id" type="text" default="" label="Section Search Id" description="Search articles by a particular section" />
Code: Select all
<input type="hidden" name="section_id" value="<?=$params->get('section_search_id')?>" />
Code: Select all
$post['section_id'] = JRequest::getString('section_id', null, 'post');
Code: Select all
$section_id = urldecode(JRequest::getString('section_id'));
$this->setSearch($keyword, $match, $ordering,$section_id);
Code: Select all
function plgSearchContent( $text, $phrase='', $ordering='', $areas=null, $section_id=null ) {
...
Code: Select all
$results = $dispatcher->trigger( 'onSearch', array(
$this->getState('keyword'),
$this->getState('match'),
$this->getState('ordering'),
$areas['active'],
$this->getState('section_id'))
);
Code: Select all
. ($section_id ? " AND a.sectionid=$section_id " : '')
Code: Select all
if ($section_id) {
$results = array();
if(count($rows)) {
foreach($rows as $row) {
$new_row = array();
foreach($row AS $key => $article) {
if(searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) {
$new_row[] = $article;
}
}
}
$results = array_merge($results, (array) $new_row);
}
return $results;
}
- elfif
- Joomla! Intern
- Posts: 68
- Joined: Fri Dec 23, 2005 1:33 pm
- Location: Bordeaux - France
- Contact:
Re: Search just one category or section
Hello, did you succeed to make it work?
I've adapted it for categories (with $cat_id/cat_id/catit ) but I don't have results for section only. The results are the same as the standard search process.
Any help someone?
I've adapted it for categories (with $cat_id/cat_id/catit ) but I don't have results for section only. The results are the same as the standard search process.
Any help someone?
Keep smiling with the sun and singing with the birds
www.atelier51.com
www.atelier51.com
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Hi, Elfif.
You said you "adapted it for categories". Are you trying to search by sections or categories? Have you tried the 6 steps exactly how I described?
It works for me. The site I'm using it on goes live in 2 weeks. PM me then and I'll give you the URL if you want to see the implementation.
You said you "adapted it for categories". Are you trying to search by sections or categories? Have you tried the 6 steps exactly how I described?
It works for me. The site I'm using it on goes live in 2 weeks. PM me then and I'll give you the URL if you want to see the implementation.
- elfif
- Joomla! Intern
- Posts: 68
- Joined: Fri Dec 23, 2005 1:33 pm
- Location: Bordeaux - France
- Contact:
Re: Search just one category or section
I'm trying to search by categories, and tried your 6 steps like described, but I replaced section_id by cat_id evrywhere needed...
Do you think I'm going wrong ?
Do you think I'm going wrong ?
Keep smiling with the sun and singing with the birds
www.atelier51.com
www.atelier51.com
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Sorry, Elfif. I have only implemented my work-around for a section search. You might think simply doing a s/section/cat/ everywhere would work for categories - but Joomla is a funny beast. You may have to spend some more time trying to figure out what's going on.
If I come across the need to search by categories, I'll update the post.
If I come across the need to search by categories, I'll update the post.
- elfif
- Joomla! Intern
- Posts: 68
- Joined: Fri Dec 23, 2005 1:33 pm
- Location: Bordeaux - France
- Contact:
Re: Search just one category or section
Thanks Yekibud.
I'm going to try your workaround by moving my articles in a brand new section !
I'll tell you if it works this way
Thanks again for your answers
I'm going to try your workaround by moving my articles in a brand new section !
I'll tell you if it works this way
Thanks again for your answers
Keep smiling with the sun and singing with the birds
www.atelier51.com
www.atelier51.com
- elfif
- Joomla! Intern
- Posts: 68
- Joined: Fri Dec 23, 2005 1:33 pm
- Location: Bordeaux - France
- Contact:
Re: Search just one category or section
Hello Yekibud,
I've tried your workaround for section search only. And I always have results for entire site... Can't understand where my problem is...
For beginning, could you please tell me where exactly you pasted your lines at step 6 ?
Thanks for your help !
I've tried your workaround for section search only. And I always have results for entire site... Can't understand where my problem is...
For beginning, could you please tell me where exactly you pasted your lines at step 6 ?
Thanks for your help !
Keep smiling with the sun and singing with the birds
www.atelier51.com
www.atelier51.com
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Hi, Elfif.
$section_id is an optional parameter that I added to the setSearch() and plgSearchContent() methods (cf. step 4 & 5) which adds the article sectionid field to the WHERE clause (if it exists) in step 6.
Are you setting the "Section Search Id" parameter in your search module?
$section_id is an optional parameter that I added to the setSearch() and plgSearchContent() methods (cf. step 4 & 5) which adds the article sectionid field to the WHERE clause (if it exists) in step 6.
Are you setting the "Section Search Id" parameter in your search module?
- elfif
- Joomla! Intern
- Posts: 68
- Joined: Fri Dec 23, 2005 1:33 pm
- Location: Bordeaux - France
- Contact:
Re: Search just one category or section
Yes yes of course, I've understood your way of thinking. Ive found your trick really useful and smart, because you can copy the seacrh module and customize easily your searches.
Nice work, but I'm not so fluent as you with php and I can't understand where the thing goes wrong...
Nice work, but I'm not so fluent as you with php and I can't understand where the thing goes wrong...
Keep smiling with the sun and singing with the birds
www.atelier51.com
www.atelier51.com
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
What version of Joomla are you using?
If you set $debug = 1 in configuration.php, do you get any messages?
Send me the following files, and I'll take a quick look to see if everything looks right:
mod_search.xml
mod_search/tmpl/default.php
com_search/controller.php
com_search/models/search.php
plugins/search/content.php
Otherwise, without access to your environment, I'm not sure how I can help troubleshoot. I may try to make the work-around plugable, which may help - but probably not for several weeks.
If you set $debug = 1 in configuration.php, do you get any messages?
Send me the following files, and I'll take a quick look to see if everything looks right:
mod_search.xml
mod_search/tmpl/default.php
com_search/controller.php
com_search/models/search.php
plugins/search/content.php
Otherwise, without access to your environment, I'm not sure how I can help troubleshoot. I may try to make the work-around plugable, which may help - but probably not for several weeks.
- elfif
- Joomla! Intern
- Posts: 68
- Joined: Fri Dec 23, 2005 1:33 pm
- Location: Bordeaux - France
- Contact:
Re: Search just one category or section
I'm using Joomla 1.5.9
Debug information are not really readable for me. I can't find the problem
I've copied debug results in a text file, and added it to other files you asked for.
I'm sending all of them via PM.
Thanks again...
Debug information are not really readable for me. I can't find the problem
I've copied debug results in a text file, and added it to other files you asked for.
I'm sending all of them via PM.
Thanks again...
Keep smiling with the sun and singing with the birds
www.atelier51.com
www.atelier51.com
- freerider
- Joomla! Apprentice
- Posts: 26
- Joined: Wed Apr 12, 2006 10:42 am
- Contact:
Re: Search just one category or section
Hi, yekibud
I'have tryed to implement your soulution for 4 or 5 times from scratch,
but I allways end up with "blank screen result" when testing search module.
I guess I'm doing something wrong.
I would be very thankfull if you could publish or send me copies of the required files.
I'm using joomla 1.5.10
I'have tryed to implement your soulution for 4 or 5 times from scratch,
but I allways end up with "blank screen result" when testing search module.
I guess I'm doing something wrong.
I would be very thankfull if you could publish or send me copies of the required files.
I'm using joomla 1.5.10
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Hi, freerider.
Sorry - nobody seems to have had any luck implementing my work-around. I've attached the files - but I think I'm going to have to test on a fresh install or try to make it plugable in order for this to be useful. I'll see if I can put a little time into this today.
Btw, the blank page is probably a PHP error. Set debug=1 in your config and you should get a more meaningful message.
Sorry - nobody seems to have had any luck implementing my work-around. I've attached the files - but I think I'm going to have to test on a fresh install or try to make it plugable in order for this to be useful. I'll see if I can put a little time into this today.
Btw, the blank page is probably a PHP error. Set debug=1 in your config and you should get a more meaningful message.
You do not have the required permissions to view the files attached to this post.
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Damn - sorry guys - I forgot one step in my explanation. You need to add a section_id parameter to the setSearch function in the search model (com_search/models/search.php):
I just tested this with a fresh install of 1.5.14 and it works. (Don't forget to set the section id in the the search module.)
I would recommend making the modifications yourself, since I don't know if anything else has changed in the search functionality in 1.5.14, but if you want to overwrite the files, use the attached zip (instead of the one from my previous post). I added the small changes I just mentioned.
hth
Code: Select all
function setSearch($keyword, $match = 'all', $ordering = 'newest', $section_id=null)
{
if(isset($keyword)) {
$this->setState('keyword', $keyword);
}
if(isset($match)) {
$this->setState('match', $match);
}
if(isset($ordering)) {
$this->setState('ordering', $ordering);
}
if(isset($section_id)) {
$this->setState('section_id', $section_id);
}
}
I would recommend making the modifications yourself, since I don't know if anything else has changed in the search functionality in 1.5.14, but if you want to overwrite the files, use the attached zip (instead of the one from my previous post). I added the small changes I just mentioned.
hth
You do not have the required permissions to view the files attached to this post.
- freerider
- Joomla! Apprentice
- Posts: 26
- Joined: Wed Apr 12, 2006 10:42 am
- Contact:
Re: Search just one category or section
Thank you!!! a milion!!!
It work's
I had to do one minor change... in /mod_search/temp/default.php
I changed
to
and becouse I require to limit search to more than one section
I changed ... in /plugins/search/content.php
to
I allso tried to implement to limit search by category. And it all went without problem.
Now I have option of limiting search by categories or sections... Yeeaj!!!
If you need solution, see my attached file (it is tested on Joomla 1.5.10!!!!!)
Yekibud thanks again!!!
It work's
I had to do one minor change... in /mod_search/temp/default.php
I changed
Code: Select all
<input type="hidden" name="section_id" value="<?=$params->get('section_search_id')?>" />
Code: Select all
<input type="hidden" name="section_id" value="<?php echo $params->get('section_search_id')?>" />
I changed ... in /plugins/search/content.php
Code: Select all
. ($section_id ? " AND a.sectionid=$section_id " : '')
Code: Select all
. ($section_id ? " AND a.sectionid IN ($section_id) " : '')
Now I have option of limiting search by categories or sections... Yeeaj!!!
If you need solution, see my attached file (it is tested on Joomla 1.5.10!!!!!)
Yekibud thanks again!!!
You do not have the required permissions to view the files attached to this post.
Last edited by freerider on Thu Oct 15, 2009 8:35 am, edited 4 times in total.
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Oh, good. I'm so glad I didn't post something that just made people chase their tails. ;-)
-
- Joomla! Apprentice
- Posts: 7
- Joined: Fri Apr 03, 2009 9:32 am
Re: Search just one category or section
it works
but when you do a second search with the searchbox on the resultpage (not the module), he searches the complete site again. the parameter section_id is shown in the url, but the value remains empty.
its propably in 'components/com_search/views/search/view.html.php'
any thoughts?
but when you do a second search with the searchbox on the resultpage (not the module), he searches the complete site again. the parameter section_id is shown in the url, but the value remains empty.
its propably in 'components/com_search/views/search/view.html.php'
any thoughts?
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
Two thoughts:
1. Add some CSS to hide the search component. That way the user always has to use the module.
2. Pass the section id to the component.
1. Add some CSS to hide the search component. That way the user always has to use the module.
Code: Select all
#searchForm {
display: none;
}
-
- Joomla! Apprentice
- Posts: 6
- Joined: Sat Oct 03, 2009 3:17 pm
Re: Search just one category or section
i'm having trouble with step 6.. not sure where the code is supposed to go.
edit: nevermind.. downloaded the attachment and got it working! thanks!
edit: nevermind.. downloaded the attachment and got it working! thanks!
-
- Joomla! Apprentice
- Posts: 38
- Joined: Tue Nov 10, 2009 4:09 pm
Re: Search just one category or section
Thanks Alot to all for the help here.
Can any one tell me, whether this functionality is available in a module yet? I need to Make the default Search an Advance search where it can select any of the sections/Categories [In the site] and do the search only those sections or categories.
I have searched and i have found one but that is Commercial.
This is what i want: http://jxtended.com/search.html?q=finder
any Ideas?
Can any one tell me, whether this functionality is available in a module yet? I need to Make the default Search an Advance search where it can select any of the sections/Categories [In the site] and do the search only those sections or categories.
I have searched and i have found one but that is Commercial.
This is what i want: http://jxtended.com/search.html?q=finder
any Ideas?
-
- Joomla! Apprentice
- Posts: 27
- Joined: Tue Jan 13, 2009 4:32 pm
- Location: Sacramento, California
Re: Search just one category or section
I've had this on my list to make plugable for months. Once I do I'll post to this thread. But I can't say for sure when I'll be able to get around to it. My hope is "soon."