editing com_search to find more from other components

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

editing com_search to find more from other components

Post by codejoy » Thu Dec 06, 2007 10:39 pm

I have installed a few more components, and i would like to search the contents of these components by modifying the com_search method to do so.  Though I am new to joomla and I am not 100% sure where to start looking, I assumed it would be a matter of adding to the sql query the search has to call somehow into the db, like basically adding the tables from the components I know that will be installed (namely e-portfolio and seyret video module).  The seyret module has a search for those that use it but its seperate and not uniform with the rest of a joomla based site.  So any pointing in the right direction would help.  I poked around the com_search folder and saw the search.html.php and the search.php but I cannot figure out where the actual calls into the SQL db are being made... like how does it know what tables to search to bring back your main results the search already returns.

Thanks
Shane

User avatar
manuman
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 211
Joined: Fri Aug 12, 2005 1:58 am
Location: Albany - Western Australia
Contact:

Re: editing com_search to find more from other components

Post by manuman » Fri Dec 07, 2007 12:42 pm

Hi there,


You don't any existing files to extend search. You can extend search's by creating searchbots(plugin). If you have a look at some of the standard installed ones(weblinks is a good option) then you'll see how they work. They are found in plugins/search in your Joomla! file system.

If your comfortable in php then the rest is a breeze.

Cheers
Shayne
Core Team Member :: Project Manager & Foundation WG Coordinator
OSM Board Member :: Treasurer
Vote for Joomla! http://www.packtpub.com/nominations-homepage

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Sat Dec 08, 2007 7:03 am

I don't have my main dev machine here, but I just downloaded joomla to the pc I am to start poking around the files and it seems I don't have a plugin folder anywhere.  I see a modules and components but no plugins folder.
Thanks,
Shane

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: editing com_search to find more from other components

Post by Opie » Sun Dec 09, 2007 6:13 am

codejoy wrote:I don't have my main dev machine here, but I just downloaded joomla to the pc I am to start poking around the files and it seems I don't have a plugin folder anywhere.  I see a modules and components but no plugins folder.
Thanks,
Shane

You did not specify which version of Joomla! you are referring to.  It sounds like you are referring to 1.0.x series.  The mambots folder is the equivalent to the plugins folder in Joomla! 1.5 series.
http://springhillalumni.org • Springhill High School Alumni Association

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Mon Dec 10, 2007 4:32 am

yes its 1.0, I see the file but I am confused by say the content.searchbot.  I am guessing its searching one of the content tables ?  where is the table name being specified, I found the query:
$query = "SELECT params"
. "\n FROM #__mambots"
. "\n WHERE element = 'content.searchbot'"
. "\n AND folder = 'search'"


but the __mambots and the element and folder confuse me.  Whats __mambots?  what is the element in the WHERE ? and whats the folder in AND its not the sql i am used to and cannot figure out whre it is specifying an actual table to query.  Though it does seem once I figure this out I can just add my own searchbot for say the video content and also the eportfolio content?

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: editing com_search to find more from other components

Post by Opie » Mon Dec 10, 2007 3:06 pm

The query you listed was to extract the parameters for that mambot (plugin).  To see the other queries, you will need to scroll further down.
http://springhillalumni.org • Springhill High School Alumni Association

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Mon Dec 10, 2007 9:47 pm

okay I see.. i did reopen the newsfeeds.php file and see the query.  Most of it makes sense: but I am curious as to what the FROM is getting from?  i see the #__newsfeeds and the #__categories , I don't see where those are defined or where they are coming from, I am not sure if this is php (I have some limited experience in php but this is sorta new to me).  I also noted a $database->Quote( _SEARCH_NEWSFEEDS ) which was suprising as well...

I know I can figure this out but my general methods of hacking this stuff isn't flying here.  I tried to go into my joomla install under administrator and unpublish and publish the search mambots to see how its working.  I also noticed that there is a line in the final query (again using the newsfeeds example) that says:
"\n CONCAT( 'index.php?option=com_newsfeeds@task=view@feedid=', a.id ) AS href, " which I wasn't sure what that itself was doing... though noticing I am sure the categories search and that replace ?option=com_newsfeeds with some other components, and I am sure for the seyret video and the e-portfolio I would be doing the same (replacing the com_newsfeeds with the other components...)

still not sure where it knows to access the tables.  Seems to me for my searches I would have to determine whats searchable (say video title, etc) and change the query to deal with that those fields from my particular table i want to search..

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: editing com_search to find more from other components

Post by Opie » Mon Dec 10, 2007 10:01 pm

The FROM statement is telling you which table in the database to get the results from.  Joomla! will replace the #__ of the table names with the database prefix as defined in the configuration.php file.

The _SEARCH_NEWSFEEDS inside the parenthesis is a variable.  Previously in that file that variable was defined.

The CONCAT SQL statement was combining the a predefined link ('index.php?option=com_newsfeeds@task=view@feedid=') with the article id (a.id) and assigning it to a field of href for the returned record.

That is correct.  You will need to supply in your search mambot (plugin) what fields you want searchable.
http://springhillalumni.org • Springhill High School Alumni Association

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Mon Dec 10, 2007 10:10 pm

Thank You, I am beginning to see how truly dynamic and well thought out Joomla is for extending.  It seems to me then, that if i were to create say an eportfolio search mambot the files it might have are:

mambots:  eportfolio.searchbot.php, eportfolio.searchbot.xml (not overly sure what the xml file does).  and inside that query somewhere i would have that url ('index.php?option=com_newsfeeds@task=view@feedid=') with the ('index.php?option=com_eportfolio@task=view@feedid=')...something to that effect, making sure the eportfolio.searchbot.php is querying the correct database fields.  then I guess I just make sure that file is there and publish that mambot and I am good to go for searching eportfolios...

or at least this is what I am thinking, thank you again for your prompt and courteous responses.

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: editing com_search to find more from other components

Post by Opie » Mon Dec 10, 2007 10:31 pm

Is there an eportfolio component?  If so, does it have a task labeled view? Or include a feed id ?
http://springhillalumni.org • Springhill High School Alumni Association

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Mon Dec 10, 2007 10:36 pm

There is an eportfolio component, since im helping a friend with his joomla based site I am not sure where it came from...so I cannot say if it has a feed id? or a task labeled view....this could hold true for that seyret video component too from:

http://www.joomlaholic.com/

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: editing com_search to find more from other components

Post by Opie » Mon Dec 10, 2007 10:40 pm

In the portfolio component, how does it display a portfolio?  That is the type of link you would supply there.

The same concept would work for the seyret component.
http://springhillalumni.org • Springhill High School Alumni Association

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Mon Dec 10, 2007 10:43 pm

ahhh okay i see, is that defined by what files are in a component? i.e. its a labeled view if there is a component_name.html file in the component folder?
etc.. ? or is that defined what kind of view it is (feed id, labled view, other) in some other manner?

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: editing com_search to find more from other components

Post by Opie » Mon Dec 10, 2007 10:48 pm

I'm not sure.  I have not coded much (read any) for the 1.0.x series.  I'm also just beginning to code php for the one component I'm working on.

What I would do at the moment, and I'm sure there are other ways to do this, would be to view a few of the portfolios.  Check the link provided to get to each portfolio and note the differences.  Hopefully, the id of the portfolio is the difference.  You could then use the common aspects of the link in your search SQL CONCAT statement. 

Figuring out which fields to include in your search may require a bit more fiddling with the component and its' associated tables.
http://springhillalumni.org • Springhill High School Alumni Association

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Mon Dec 10, 2007 10:53 pm

I am comfy with the database stuff, but the link stuff is whats throwing me off, what is its purpose? is that a like "returned link" so to speak that is processed by something else in order to provide the results of a search?

thanks again for all the help really its really helping.

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: editing com_search to find more from other components

Post by Opie » Mon Dec 10, 2007 10:59 pm

When you do a search, that link "stuff" is what will be shown on the search results page.  It will need to go to a valid page or the users of the site won't find it very useful.
http://springhillalumni.org • Springhill High School Alumni Association

codejoy
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Dec 06, 2007 10:10 pm

Re: editing com_search to find more from other components

Post by codejoy » Mon Dec 10, 2007 11:00 pm

okay it just made sense, that link is partially whats returned from the database, i.e. if you search for a news blurb that has the word "firefox" in it, and there are three articles with that word, then it will return in the link the proper id's and what not to display the articles (or the links in the page that list the articles).


Post Reply