Gossamer Forum
Home : Products : Links 2.0 : Customization :

Using Search.cgi to search two database files

Quote Reply
Using Search.cgi to search two database files
Can someone please tell me how I can allow users to add links to one of two links.db files and then use just one search.cgi file to search them both?

For example, I run a music site and want a database for links to music sites and a database for links to Music Files. I suppose I can create a second add.cgi file so that the links can be added to another database file, but then how do I get the search script to search both databases?

Hope I make sense!

Also Ive installed the mod that lets you search sub categories, but when you perform a search it ALWAYS says *Error:No Search Results* even if there are links in the sub categories. Why is this?



Thankyou
From Paul Wilson.
Quote Reply
Re: Using Search.cgi to search two database files In reply to
Also I was just thinking, is there a way to get Links to build the directory using both Links.db files?

Thankyou
From Paul Wilson.
Quote Reply
Re: Using Search.cgi to search two database files In reply to
You will need to modify search.cgi to search both databases. Look at sub search, search.cgi to see how it is done for one database. You should probably change sub search to sub search1 and create a sub search2 subroutine. The first search subroutine would return search results from one database and the second search subroutine would return search results from the second database.

You would have to call each search subroutine separately.

It gets really complicated though because you will have a lot of modifying to do and not just in search.cgi. Why not just let your users select which database they want to search? That sounds simpler to me. You could put two different search boxes on your advanced search page, for example, one for the music sites, another for the music files. Users could then just put their search queries in the appropriate search boxes.



- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Using Search.cgi to search two database files In reply to
Does your site have cron capability? If so, you could setup an event to rebuild both databases at the same time.

I just do not understand something here though. Why not just have one database to begin with? You first Category could be MP3 Sites and the second category could be MP3 Files. Each of those categories would have sub-categories with the names you now use as top-level categories in each database? While this might involve a restructuring of your links.def, etc., it would solve a lot of your problems.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Using Search.cgi to search two database files In reply to
Thanks for your help Bobsie.

Basically the reason I thought I needed two databases was because I needed different fields in Links.db for Music Sites and files, because for music sites I can use the database that I have at the moment because it just requires people to entertheir URL, name email etc...but when people add links to music files, I want them to fill in the form with File Size, track length etc...

Can this be done by creating 2 add.cgi scripts with different forms? ...can I add links to one database with different formants?

Eg. One link in the database would be like the default
ID|TITLE|URL|DESCRIPTION etc

and then additions from the other add.cgi scripts would add links to the directory in the format..
ID|TITLE|DESCRIPTION|FILESIZE|TRACKLENGTH etc..

Would this work?
What would I need to change?

Thankyou,
From Paul Wilson.
Quote Reply
Re: Using Search.cgi to search two database files In reply to
What I would do is modify the forms in the add/modify templates. For example you could have one section that is filled in for ALL link additions and another section for additional information when the link addition is for music files that would pick up the file information you want.

This would require changing your links.def and links.db and the add/modify templates. That might seem like a lot of work but it would be less work in the long run than trying to have two databases and modify scripts to handle both in a combined manner. It would also save you some disk space as well because only one set of files is needed for the entire Links installation.

Just my thoughts.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Using Search.cgi to search two database files In reply to
If I give you some information about what I want to do, could you explain what I need to change because I am not as knowledgeable as you in Perl?

If so I would be most grateful!


Thankyou,
From Paul Wilson.
Quote Reply
Re: Using Search.cgi to search two database files In reply to
Hi Bobsie,

Im getting to the point now where I really need to modify Links 2.0 so I can implement what I was talking about earlier...which is that I want people to be able to add music websites to my directory and also links to music files!

Please could you explain what I need to change!

For the website results, the original links.def is fine
eg. ID|TITLE|URL|DESCRIPTION etc
but for music file links in need the results in the format
ID|TITLE|URL|FILESIZE|TRACKLENGTH etc

Can the two different types of links be added to one links.db file?

I hope Im not asking too much but please could you tell me step by step what I need to alter!

I am most grateful!

Thankyou,
From Paul Wilson.

PS. I already have a categories.db file that includes categories for music websites and music files, so the categories database doesnt need altering I dont think!

Quote Reply
Re: Using Search.cgi to search two database files In reply to
http://www.gossamer-threads.com/...ew=&sb=&vc=1

Quote Reply
Re: Using Search.cgi to search two database files In reply to
.

Thankyou,
From Paul Wilson.