The Joomla! Forum ™



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.



Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Thu May 22, 2008 8:13 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Dec 13, 2007 9:20 pm
Posts: 11
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/option,com_mtree/task,viewlink/link_id,2700/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!


Top
 Profile  
 
PostPosted: Mon Jun 02, 2008 5:50 am 
Joomla! Intern
Joomla! Intern

Joined: Tue Apr 17, 2007 2:11 pm
Posts: 52
I have a similar need for this...

has anyone figured out a way to do it?


Top
 Profile  
 
PostPosted: Thu Jun 05, 2008 11:01 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Dec 13, 2007 9:20 pm
Posts: 11
I stall haven't found a solution for this - seems like there should be a canned solution for this, no?

*bump*


Top
 Profile  
 
PostPosted: Wed Jun 25, 2008 4:49 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Dec 13, 2007 9:20 pm
Posts: 11
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?


Top
 Profile  
 
PostPosted: Thu Nov 13, 2008 11:52 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Sep 28, 2007 10:47 am
Posts: 26
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.


Top
 Profile  
 
PostPosted: Thu Nov 13, 2008 6:02 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Dec 13, 2007 9:20 pm
Posts: 11
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!


Top
 Profile  
 
PostPosted: Tue Dec 23, 2008 6:21 am 
Joomla! Intern
Joomla! Intern

Joined: Thu Dec 13, 2007 3:59 pm
Posts: 60
I'd like help with doing this too.


Top
 Profile  
 
PostPosted: Tue Jan 13, 2009 6:40 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed May 28, 2008 1:49 am
Posts: 11
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


Top
 Profile  
 
PostPosted: Tue Jan 13, 2009 7:20 am 
Joomla! Intern
Joomla! Intern

Joined: Thu Dec 13, 2007 3:59 pm
Posts: 60
Search feature works okay for me on php5. I just wish you could type in more than 20 characters.


Top
 Profile  
 
PostPosted: Mon Mar 02, 2009 6:16 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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)

Code:
<param name="section_search_id" type="text" default="" label="Section Search Id" description="Search articles by a particular section" />


2. pass section id to search component via post (mod_search/tmpl/default.php)

Code:
<input type="hidden" name="section_id" value="<?=$params->get('section_search_id')?>" />


3. add section id to model parameters from component controller (com_search/controller.php)

Code:
$post['section_id'] = JRequest::getString('section_id', null, 'post');


4. add section_id parameter to setSearch method in model and add to constructor call (com_search/models/search.php)

Code:
$section_id = urldecode(JRequest::getString('section_id'));
$this->setSearch($keyword, $match, $ordering,$section_id);


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)

Code:
function plgSearchContent( $text, $phrase='', $ordering='', $areas=null, $section_id=null ) {
...


and

Code:
$results = $dispatcher->trigger( 'onSearch', array(
     $this->getState('keyword'),
     $this->getState('match'),
     $this->getState('ordering'),
     $areas['active'],
     $this->getState('section_id'))
);


6. add section_id conditionally to article search query and return results (plugins/search/content.php)

Code:
. ($section_id ? " AND a.sectionid=$section_id " : '')


and, right after the article query,

Code:
   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;
   }



hth


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 2:03 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 23, 2005 1:33 pm
Posts: 42
Location: Bordeaux - France
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?

_________________
Keep smiling with the sun and singing with the birds
www.atelier51.com


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 3:41 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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.


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 8:09 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 23, 2005 1:33 pm
Posts: 42
Location: Bordeaux - France
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 ?

_________________
Keep smiling with the sun and singing with the birds
www.atelier51.com


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 9:48 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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.


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 10:12 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 23, 2005 1:33 pm
Posts: 42
Location: Bordeaux - France
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

_________________
Keep smiling with the sun and singing with the birds
www.atelier51.com


Top
 Profile  
 
PostPosted: Mon Jun 08, 2009 7:50 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 23, 2005 1:33 pm
Posts: 42
Location: Bordeaux - France
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... :geek:
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


Top
 Profile  
 
PostPosted: Mon Jun 08, 2009 2:52 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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?


Top
 Profile  
 
PostPosted: Mon Jun 08, 2009 4:11 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 23, 2005 1:33 pm
Posts: 42
Location: Bordeaux - France
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...

_________________
Keep smiling with the sun and singing with the birds
www.atelier51.com


Top
 Profile  
 
PostPosted: Mon Jun 08, 2009 4:31 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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.


Top
 Profile  
 
PostPosted: Tue Jun 09, 2009 3:42 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 23, 2005 1:33 pm
Posts: 42
Location: Bordeaux - France
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...

_________________
Keep smiling with the sun and singing with the birds
www.atelier51.com


Top
 Profile  
 
PostPosted: Fri Oct 09, 2009 8:11 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Apr 12, 2006 10:42 am
Posts: 26
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


Top
 Profile  
 
PostPosted: Tue Oct 13, 2009 3:06 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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.


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Tue Oct 13, 2009 6:18 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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):

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


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Wed Oct 14, 2009 4:20 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Apr 12, 2006 10:42 am
Posts: 26
Thank you!!! a milion!!!
It work's

I had to do one minor change... in /mod_search/temp/default.php
I changed
Code:
<input type="hidden" name="section_id" value="<?=$params->get('section_search_id')?>" />

to
Code:
<input type="hidden" name="section_id" value="<?php echo $params->get('section_search_id')?>" />


and becouse I require to limit search to more than one section
I changed ... in /plugins/search/content.php
Code:
. ($section_id ? " AND a.sectionid=$section_id " : '')

to
Code:
. ($section_id ? " AND a.sectionid IN ($section_id) " : '')


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!!! 8)
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.

Top
 Profile  
 
PostPosted: Wed Oct 14, 2009 4:28 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
Oh, good. I'm so glad I didn't post something that just made people chase their tails. ;-)


Top
 Profile  
 
PostPosted: Wed Oct 28, 2009 3:08 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Apr 03, 2009 9:32 am
Posts: 7
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?


Top
 Profile  
 
PostPosted: Wed Oct 28, 2009 3:22 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
Two thoughts:

1. Add some CSS to hide the search component. That way the user always has to use the module.
Code:
#searchForm {
    display: none;
}


2. Pass the section id to the component.


Top
 Profile  
 
PostPosted: Thu Nov 05, 2009 8:08 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Oct 03, 2009 3:17 pm
Posts: 6
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!


Top
 Profile  
 
PostPosted: Fri Jun 11, 2010 9:02 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Nov 10, 2009 4:09 pm
Posts: 38
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?


Top
 Profile  
 
PostPosted: Fri Jun 11, 2010 9:27 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 4:32 pm
Posts: 27
Location: Sacramento, California
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."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2  Next



Who is online

Users browsing this forum: No registered users and 5 guests


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 post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group