Gossamer Forum
Home : Products : Gossamer Links : Pre Sales :

Search only in cat

Quote Reply
Search only in cat
Hi all,

Widgetz has written this mod to 1.x, but i cant fix it to 1.11.
(http://gossamer-threads.com/perl/forum/newreply.pl?Cat=&Board=LSQLDisc&Number=68243&page=&view=&what=showflat&sb=&part=1&vc=1)

Has someone an idea how to do that?
(Hey Pugdog, i cant wait or upgrade, i need it just for 1.11)

Robert

Quote Reply
Re: Search only in cat In reply to
I have not tested the following codes...but if they work, cool! If not, then may be someone can provide some tweaks that will work....

1) Add the following codes as global variables in the my (); codes in the sub main routine:

Code:

$categories, $categoryid


2) Then add the following codes:

Code:

($in->param('categoryid') =~ /^(\d+)$/) ? ($categoryid = $1) : (u
ndef $categoryid);


AFTER the following codes:

Code:

($in->param('order') =~ /^(score|category)$/i) ? ($order = uc $1) : ($or
der = 'CATEGORY');


3) Then add the following codes:

Code:

# Search Category Codes
if ($categoryid) {
$categories = $categoryid;
my $sth = $linkdb->prepare (" SELECT SubCategoryID FROM Category
Heiarchy WHERE CategoryID = $categoryid ");
$sth->execute();
while (my $cat = ($sth->fetchrow_array)[0]) {
$categories .= ",$cat";
}
}
[

AFTER the following codes:

Code:

# Now let's search the links table, but first figure out any filters.
$linkdb = new Links::DBSQL "$LINKS{admin_root_path}/defs/Links.
def";


4) Then add the following codes in the hash codes for the &site_search_results:

Code:

categoryid => $categoryid


5) Then add the following codes in your category.html file:

Code:

<input type="radio" name="categoryid" value="<%categoryid%>"><%category_name%></option>
<input type="radio" name="categoryid" value=""> Whole Site</option>


Again...I do not know if this will work...I have not built my site yet...so, the CategoryHierarchy table has not been built.

Regards,

Eliot Lee


Quote Reply
Re: Search only in cat In reply to
1. With:
<input type="radio" name="category" value="<%category_id%>"><%category_name%></option>
<input type="radio" name="category" value=""> Whole Site</option>

in category.html and

($in->param('category') =~ /^(\d+)$/) ? ($category = $1) : (undef $category);

we wait for an input "category" in search.cgi; if its there, it will be proofed
( =~ /^(\d+)$/) ) and set to the input, when a number or set to undef if not.

So we could decide, its a global search (undef) or a category-search (=$1)

Now i have decided: a seach in a subcat should search all!!! cats, but links only in the subcat and their subcats.
So i could get all the cat ids with this:

##--## Search Category Codes
if ($category) {

$sth = $catdb->prepare ( " SELECT SubCategoryID
FROM CategoryHierarchy
WHERE CategoryID = $category ");
$sth->execute() or die $DBI::errstr;
****
}
##--##

With i got the list for all my subcats to the input category.

**** Maybe with this ??? i could save them to $categories
while (my ($categories) = $sth->fetchrow_array())

So i should have an array with subcats-IDs init. I still need the aktuell id in $category !!!
Maybe with: $categories .= $categories, $category ???

Maybe it runs with ... as suggested:
while (my $cat = ($sth->fetchrow_array)[0]) {$categories .= ",$cat";} ???

I dont know it.

The next and important step is:

Point 1:
$linkdb = new Links::DBSQL "$LINKS{admin_root_path}/defs/Links.def";

then:

Point2:
$link_hits = $linkdb->query ( { query => $query, mh => $mh, nh => $nh, filter => \%filter, ww => $ww } );

i think here is the point to go on; we dont want a query tru the whole $linkdb; so we must reduce this.


I have tried it with no effort with:

Point1:
$sth = $linkdb->prepare ( " SELECT *
FROM Links
WHERE CategoryID = $categories ");
$linkdb = $sth->execute() or die $DBI::errstr;

and then do the query: (Point2)

I think its a small thing at this point, but im still no perler :-(

Hope someone could fix it.

Robert
Quote Reply
Re: Search only in cat In reply to
In Reply To:
Dont understand, why you post this?! If the errors will be corrected it could maybe give out the subcats for a cat?!
I was trying to help you...but with this attitude, I will be leary about posting ANY codes for you in the future. Good luck with your links project!

Tongue

Regards,

Eliot Lee

Quote Reply
Re: Search only in cat In reply to
Hey Eliot, calm down. I won´t attack you, i were only surprised that you have repeated parts from the org-mod for 1.02b.
Im no perler at all, but the code you write is less useful, isnt it?

So what do you think, should we do this damned mod together or play little games like little boys?

Come on, send me a smile and forget it, if i have choosen the wrong words.

Robert

PS: I would really like to write you directly, but it seems you have set private messages off :-(



Quote Reply
Re: Search only in cat In reply to
Use some manners like Thanks for the codes, but I don't understand...the codes look very similar to the codes posted by widgetz. The "tone" in your message led me to believe that you were ungrateful about my efforts and guess what? That doesn't fly with me very well.

Sorry...anyway...good luck finding a solution.

Regards,

Eliot Lee