Gossamer Forum
Home : Products : Links 2.0 : Customization :

Cool little mod.

Quote Reply
Cool little mod.
Ok, i just made a mod that i'd like to share. With this mod, you can have 'types' of links. i.e., on a site that lists tv and radio webstations (my intention), a user can search for tv stations, radio stations, or both.

if anyone wants this, i'll put it up.

--tom (i might test it in the meantime)
Quote Reply
Re: Cool little mod. In reply to
let me guess..

add new field.. Type
select field.. i guess.. (right)

something similiar to my category search.. except it searches Type..

if it's longer than that.. what else did you need to do?

right?
jerry
Quote Reply
Re: Cool little mod. In reply to
actually, its shorter than that.

this right before the links search...
if ($in{"$values[$db_type]"} | | $search_all_types) {

if you only have a couple options, can just put 'em into check boxes... so users can search the the type(s) they want, or all of them.

come to think of it, this makes the search even faster unless they're looking for everything...

[This message has been edited by garadon (edited September 30, 1999).]
Quote Reply
Re: Cool little mod. In reply to
Using Jerry's Sub-Category Search Mod, I was able to create a list of Categories in my search form that allows people to click on categories and search only in them. I also have links to categories.

Jerry's mod is very nice because it automatically will search in specific categories by using a drop-down menu.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Cool little mod. In reply to
yeesh... i post a mod and people worship widgetz and degrade me for it... man, i'd better check to see if he's got a mod out before i write anything even close to it... man, this is like if Sun were to get sued by m$ because of StarOffice... uh oh... don't get me started on m$... i'm gettin riled up for a speech about that tomorrow... gonna be belchin' fire tomorrow... and the teacher expects me to tell his class what to expect in the quarter! heh.

differences between my search and widgetz's search:

mine:
search multiple groups at a time, all at once, or only one
his:
search one group or all

mine:
check boxes to select groups
his:
pull-down menu

mine:
search for groups no matter where they are in the database
his:
search a selected area of the database

mine:
written by the programming "lower-class*" (like linux)
his:
written by 'the man**' (like windows)

*no, i'm not calling linux hackers/coders bums, but this is how they're generally viewed.
**this isn't DA MAN, but the man, who be gettin the people down.

no offense intended, none (on my part) taken. what i mean by this posting is that these are 2 different mods, like... gala and granny smith apples... similar, but preference is a matter of opinion and application.

--Tom

don't flame me for this posting... it won't be worth u'r time...

[This message has been edited by garadon (edited September 30, 1999).]

[This message has been edited by garadon (edited September 30, 1999).]
Quote Reply
Re: Cool little mod. In reply to
Garadon,

Where can we get the mod? err... people who want it.

Thanks
Quote Reply
Re: Cool little mod. In reply to
Ok... i'll be putting this up in the mods section shortly, if there's enough demand for it (doubt it).

#i promise to put this into a list when i have the time
before sub main, put this:

$search_all_types=0;$i=0;$j=0;

and then, for every 'type' you have, put these 2 lines in for it:

$i++;$j++;
if ($in{'XXXXXX'}) $j--;

at the end of that, put this:

if ($j<$i) $search_all_types=1;

then, in sub search, where you see:

# Check to see if the link matches.

paste this code block over the one that's there:
Code:
$match = 0; $andmatch = 1;
if ($in{"$values[$db_type]"} &#0124; &#0124; $search_all_types) {
if ($regexp) {
FIELD: foreach $field (@search_fields) {
$_ = $values[$field];
$or_match ?
($match = $match | | &{$regexp}) :
($match = &{$regexp});
last FIELD if ($match);
}
}
}

now, all you need to do is add a field to your links.def, and link it as $db_type= 14 (or whatever the number you added it as is.), and put checkboxes in your html with names equal to the types...

i realize this is probably one of the user-unfriendliest mods u've seen... it'll get better after i've actually gotten the chance to put it to the test, and have time to type it up better.

--Tom (not responsible if you accedentally put this in wrong and you create a virulent perl script)


[This message has been edited by garadon (edited September 30, 1999).]
Quote Reply
Re: Cool little mod. In reply to
ok.. i don't see how you're mod is "shorter"

you do add a new field called "Type" right?

i've only seen the field number thing "$db_type".. but not once you saying anything about %db_def..

why don't you just use this code..

Code:
next LINE unless ($in{'searchtype'} && $in{'searchtype'} eq $values[$db_type]);

you would put it after

Code:
$grand_total++;

or my category search mod.. if you have it..

just add the form field searchtype and you're pretty much done..

jerry

[This message has been edited by widgetz (edited September 30, 1999).]
Quote Reply
Re: Cool little mod. In reply to
hehe.. i didn't even read that flame you posted up there before i posted that..

btw.. you repeated searching multiple groups twice..

i do not even know what the heck your talking about Wink mine can search multiple categories.. you just change the code to this..

Code:
$found = 0;
unless ($in{'category'} eq "All") {
@cats = split("~~", $in{'category'});
foreach (@cats) {
($values[$db_category] =~ /^$_/) or next;
$found = 1; last;
}
next LINE unless ($found);
}
undef $found;

and that could be easily changed to search types also...

since my links 2 is in SQL now.. i no longer use any of this.. but for types.. i just use different databases.. so i can have different fields and styles.. it's nice.. although it's still capable of search all 4 databases.. quickly

degrading enough?

jerry
Quote Reply
Re: Cool little mod. In reply to
heh... you considered that a flame? nay, i was just explaining the differences... my take was only SLIGHTLY skewed, but that wasn't a flame. i'm a lot more profane when i flame. and i usually don't say 'no offence intended'

anyways... (lets get past the purile b.s., shall we? i know, most of it was on my side, but... oh well. that's what i get for growing up as an 'inner-city kid')

i said mine was shorter, because i figured your mod would take a few more lines... but then, i realized that people could just uncheck all the boxes and never get results (mmm, user stupidity), so i had to add a bunch of yet-to-be-revised clumsy code, stripping me of any advantage that i previously might have had.

and the reason that i didn't use this:
next LINE unless ($in{'searchtype'} && $in{'searchtype'} eq $values[$db_type]);
is because i'm not much of a perl programmer... admittedly, i'm not much of a programmer with ANY language... but i try, and i get done what i need to get done. maybe it's not perfect, but i've only been programming for about 5 months, and the first 2 months of those were in VB...
actually, the reason that i didn't use that was because i wanted the user to be able to search any combination of categories... which would (unless i greatly miss my mark) take a multi-select listbox or something in your case...

--Tom

BTW, u might be gettin bad vibes from me... don't mean to come accross wrong... i respect you as a programmer, i think u'r a bit full of yourself, but i really don't care about that. i also have a big ego, and i don't easily take critique from people i don't know. ugh... before i turn this into an emotional support forum, i'm gonna go.
Quote Reply
Re: Cool little mod. In reply to
a
Quote Reply
Re: Cool little mod. In reply to
Hi there, if i understood your text in the right way, you talk about modes that can do the user search more convinience.
But where can i find this mods???

What i have to do is implementing a search-form like that in the admintool, so a user can search for just one extra field like postal code; better than this would be a search like "from postal code: 3000 to 4000.
So i could do a list of isps e.g.

Is there something like that and where can i found it. I have read all the different mods but cant find this.


Robert


Quote Reply
Re: Cool little mod. In reply to
yes, you could do that with this mod. once i put the code into order (sorry, i'm really busy at work and school, so that's on a back burner), i'll mail it to you, if you want.

What you would do, is have say, range 3000 - 3999, and every listing would have a postal range number (in the type field), and you might also want the actual postal code in another field (yes, you could have it look at that field, and yes, i can write the mod for that, but not now) to show the user.

ok, that made no sense... but then, i got 1 hour and 45 minutes of sleep this weekend. (1 hour one night, 45 minutes the other)
Quote Reply
Re: Cool little mod. In reply to
for range searches.. just use something along the lines of

Code:
next unless ($values[$db_postal] >= $highrange && $values[$db_postal] <= $lowrange) if ($highrange && $lowrange);



[This message has been edited by widgetz (edited October 12, 1999).]
Quote Reply
Re: Cool little mod. In reply to
right... but, if they just wanted >500 with no lower bound?

Code:
next unless ((($values[$db_postal] <= $highrange) && $highrange) && (($values[$db_postal] >= $lowrange) && $lowrange));

that would accomidate for both... but then, the html interface for something like this would be cludgy... but then, if you put that into "advanced search options" cludginess is next to godliness...

er... nevermind
--Tom

[This message has been edited by garadon (edited October 11, 1999).]
Quote Reply
Re: Cool little mod. In reply to
hmm.. i don't think so..

i am not testing this so i don't know.. but i think that does the same exact thing as mine.. except it will skip all the links if there is no high or low set..

plus.. your < and > are flip flipped.. it would give you something greater than greatest or lesser than least if it worked right..

i would put it onto two lines like this

Code:
next if ($values[$db_postal] > $highrange) if ($highrange);
next if ($values[$db_postal] < $lowrange) if ($lowrange);

that way it is either one of them.. both of them.. or none of them..

jerry

[This message has been edited by widgetz (edited October 12, 1999).]
Quote Reply
Re: Cool little mod. In reply to
um, i disagree about the </>'s being flipped... (i did copy your code and edit it, after all)

but u'r right about the other. this should work... oh, wait... damn 'unless' operator... u'r right about the </>'s...

Code:
next if ((($values[$db_postal] <= $highrange) + !$highrange) && (($values[$db_postal] >= $lowrange) + !$lowrange));

the code may be harder to read, but this only requires 1 if statement, not 4 (woohoo! trimmed off 1µs!)

hmm... my teacher always got mad when i used code like that (the (LOGICAL)+ !$variable in a logical) last year... oh well...

--Tom
Quote Reply
Re: Cool little mod. In reply to
i'm sorry to say.. but now you are skipping the ones that are in the range.. Wink

jerry
Quote Reply
Re: Cool little mod. In reply to
Ok... i guess i'm missing something then... where exactly would you be putting this code? maybe i'm looking at it in the wrong context...

--Tom