Page 1 of 2

Search Engine for CMSMS

Posted: Wed Nov 30, 2005 12:02 pm
by Brad Jones
Hi Everyone

This isn't really module, I guess one day I could turn it into one but at the moment I can't be bothered. Anyway here is how I intergrated PHPDig in CMSMS.

Step 1:
Install PHPDig under

Code: Select all

/modules/PHPDig
Step 2:
Create User define tag called phpdig
With

Code: Select all

echo $_GET['query_string'];
Step 3:
Create Page called search
With



Also with in header

Code: Select all

{literal}
<__script__ type="text/javascript">

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

</__script>
{/literal}
Step 4:
Insert this code wear every you want a search field. ie: Somewhere in your template.

Code: Select all

<form action="http://www.yoursite.com/index.php" target="_self" method="get">
<input type="hidden" name="page" value="Search">
<input type="text" name="query_string" value=""></td>
<input type="submit" name="Submit" value="Search">
</form>
Step 5:
I also create a link directly to http://www.yoursite.com/index.php?page=search
And name it Advanced search as you will then see the rest of PHPDigs functions.

Step 6:
Customise your own PHPDig template.

Re: Search Engine for CMSMS

Posted: Wed Nov 30, 2005 7:14 pm
by petert
great stuff!
Finaly a search method that does real searching.

Implemented it today in udner half an hour. It works great!
Thanks!

Re: Search Engine for CMSMS

Posted: Thu Dec 01, 2005 2:28 am
by iNSiPiD
Hi Brad,

Interesting stuff. Do you have a live example we can look at?

It was my understadning that phpDig had some loimiations with number of pages or something, or am I dreaming? A free and a commercial version?

Also, is the crawling and caching done elsewhere?

Re: Search Engine for CMSMS

Posted: Thu Dec 01, 2005 7:41 am
by cyberman
Brad Jones wrote: Step 3:
Create Page called search
With

tag with stylesheets here. The tag is deprecated by W3C and should be only used for compatibiility with NS 1.1 ;-) .

Re: Search Engine for CMSMS

Posted: Fri Dec 02, 2005 12:39 am
by Brad Jones
To answer iNSiPiD's question, yes I do have a live version in fact I currently now have two sites using this method. Have a look at http://www.joneseng.com.au/ and also my personal site which is not quiet finished yet http://www.bjc.id.au/

Yes the admin of PHPDig is conducted from where you installed it so that would be:
http://www.yoursite.com/modules/PHPDig/admin/index.php

As far as I was aware there was only a free open source version but I guess I could be wrong.

Re: Search Engine for CMSMS

Posted: Fri Dec 02, 2005 1:28 am
by iNSiPiD
This seems to work really well, Brad. I love the relevancy of the results and the spelling suggestion on typos that near match keyowords in the spidered index.

wishy, if you're listening, could this be a viable solution as the defult search?

Could it be better integrated and installed/managed through admin?

I understand people would probably need to spider their site regularly but perhaps this, too, could be handled either by a button in admin search screem or in the bakcground with a cron job?

Re: Search Engine for CMSMS

Posted: Fri Dec 02, 2005 2:53 am
by Ted
I think it's a nice solution in the interim.  However, I have some ideas to make it more integrated.  I would say try it for now and after we get 1.0 out the door, I'll start working on a new solution.  I think it's my first order of business for post 1.0...

Re: Search Engine for CMSMS

Posted: Fri Dec 02, 2005 10:32 pm
by petert
iNSiPiD wrote: I understand people would probably need to spider their site regularly but perhaps this, too, could be handled either by a button in admin search screem or in the bakcground with a cron job?
It's already there, cron-jobs, 'wget jobs'. Comes standard with phpdig.
And it works great

Re: Search Engine for CMSMS

Posted: Sun Dec 04, 2005 11:03 pm
by iNSiPiD
I think I just may be a very happy person now but the looks I'm currently getting from work colleagues suggests something else entirely. ;)

Thanks, petert. I'll have a play imminently!

Re: Search Engine for CMSMS

Posted: Sun Dec 04, 2005 11:09 pm
by Ted
@Brad Jones, petert: Do you guys know if there is a way to use the internals of phpdig without the spider?  I'd love to be able to regster content with it instead of having to spider the pages.

Re: Search Engine for CMSMS

Posted: Mon Dec 05, 2005 9:22 am
by petert
wishy wrote: @Brad Jones, petert: Do you guys know if there is a way to use the internals of phpdig without the spider?  I'd love to be able to regster content with it instead of having to spider the pages.
I wouldn't take that aproach. Searching through the database is in my opinion not the best solution. I think that spiders always give you much better results (and all your modules and tags will work this way).

The 'old' cms I used (http://phpcms.de) had a spider and worked with flatfiles, perfect results from that search method.

Maybe some sort of hybrid form can be made? Each time a page is put in the cache it will automaticaly update the search results database through the logic of the phpdig spider?

Re: Search Engine for CMSMS

Posted: Wed Dec 07, 2005 4:39 am
by iNSiPiD
The spider multilists all the news links (possibly every instance for every page) so the results and indexing (keyword count) is screwed.

I wonder if there's a way to limit this with a regex in the spider admin.

Otherwise it works well enough, has good functionality and (once you've gone through the pain of installing PHPDig itself) integrating it into CMSMS is a piece of piss...er, really easy.

Re: Search Engine for CMSMS

Posted: Thu Dec 08, 2005 10:46 pm
by iNSiPiD
I've fixed the spidering by excluding '&' from URL paths to search by. So now my site (with the exception of News and other module data) is all wonderfully spidered.

Experiment with the spider levels. Only go as deep as your menu structure. 3 or 4 generally seems more than adequate.

All in all a good solution for the interim.

Re: Search Engine for CMSMS

Posted: Fri Feb 10, 2006 4:00 pm
by shrewsbury
This is awesome, you rock!!!  Totally easy to set up and works like a charm.

;D

Re: Search Engine for CMSMS

Posted: Fri Feb 10, 2006 10:13 pm
by kermit
a separate app for searching a db-driven web site, use of iframes? sorry, i don't see how that's "simple" compared to an internal search function that would utilize the db; something i'm surprised wasn't one of the first things added to cmsms. i was rather disappointed when i first saw that cmsms's "search" relied upon google's site-search.

don't get me wrong, it's great to see people adding functionality to cmsms, it's just that an internal search routine should be a core feature, not something you have to hack together.