simple search for users

50 views
Skip to first unread message

Dennis

unread,
Jan 13, 2009, 1:11:50 PM1/13/09
to SubjectsPlus
Hi all,

Is there a relatively easy way to let *users* do a keyword search of
the records, the same way administrators can on subsplus/control/
rxs_records/?

I'd like to add this functionality to the main subsplus/subjects/
index.php search, like so:

http://136.183.139.251/reed/subsplus/subjects/?gen_id=0

Thanks for any help!

Best,

Dennis
Web Specialist
E. H. Butler Library
Buffalo State College

Andrew Darby

unread,
Jan 13, 2009, 2:53:06 PM1/13/09
to subjec...@googlegroups.com
Hi Dennis,

Something similar is being done with the databases.php page. I've
mocked something up quickly here:

http://www.ithacalibrary.com/subjects/search.php

It searches the title and description fields of the title table.

Is this what you had in mind? (It might be good to also have, say in
the sidebar, a list of related subject guides.) I still need to tidy
this up (all the icons aren't working correctly, and ditto the print
links). Any other ideas?

I can share the code once it's tidied up, and I guess I'll include a
search page in the upcoming version 0.8.

By the way, I like your splash page, it's nicely organized.

Andrew

Reed, Jr., Dennis

unread,
Jan 14, 2009, 10:50:22 AM1/14/09
to subjec...@googlegroups.com
Hi Andrew,

Thanks for the response, and thanks for developing this great "product"!

I want to plop this title+text search onto display.php, so a user may do
either from the same page. I tried to just add the admin search code to the
display.php page (updating relative URLs of course), but I am really not
swift enough with the PHP to carry it off properly (got undefined function:
dbCall error, and the native search stopped working!).

Should it be easier to take the search code from databases.php and add it to
display.php?

Best,

Dennis

Andrew Darby

unread,
Jan 14, 2009, 11:22:26 AM1/14/09
to subjec...@googlegroups.com
Hi Dennis,

I was just tidying up that search.php page I linked to yesterday.
I've put the file in the Files section of the google groups,
search.php. This file would go in the root of the subjects folder.
You should be able to put a search box anywhere on the site, so long
as your form action points to search.php and your search term field
has a name of "searchterm". You can also use a get parameter, i.e.,
search.php?searchterm=auto .

Note that the search right now is in the form wilcard - searchterm -
wildcard, so searching "auto" would turn up the word auto as well as
automobile and zauto (if zauto were a word). A stricter match is
commented out above the query (variable $q); you could swap this in if
that works better for you.

Finally, I've got the descriptions hidden, and then revealed by a bit
of jquery magic. If you want the descriptions always showing, find
the line

<span style=\"display: none;\" class=\"toggle\">

and change the style to "display: block;"

and then if you don't want the jquery, you can delete all the stuff at
the bottom of the file. I hope this works for you. Let me know if
anything's unclear or if anything doesn't work properly. I'm going to
include this search.php in the upcoming version 0.8 of subsplus.

Oh. This page also has a little red star for a bullet--I've uploaded
that, too. bullet2.png. It would go in subjects/images/

Andrew

Reed, Jr., Dennis

unread,
Jan 14, 2009, 2:01:55 PM1/14/09
to subjec...@googlegroups.com
Thanks Andy, this is a great help!

I got search.php from the Google site, and put it in the root of the
/subjects folder. However, when I plugged the form into my test page (
http://136.183.139.251/reed/subsplus/subjects/index.php) and tried a search
, I got:

Fatal error: Call to undefined function stripP() in
/var/www/html/reed/subsplus/subjects/search.php on line 148

Best,

Dennis

Reed, Jr., Dennis

unread,
Jan 14, 2009, 2:28:33 PM1/14/09
to subjec...@googlegroups.com
However, when I type in a nonsense search like "aeaeaeaea," I DO get a note
saying there were no results! (It is only when I type a proper search term
which should return results, that I get the "fatal error" error message)

D

Andrew Darby

unread,
Jan 14, 2009, 2:39:37 PM1/14/09
to subjec...@googlegroups.com
Oops. That's a new function to try to eliminate some whitespace that
FCKeditor (the wysiwyg text editor) was adding in version 2.6.3.
Anyway, you can add the following function to control/functions.php

function stripP($text) {
///////////////////////////
// Fix FCKeditor madness!
// * check if it begins and ends with a P tag; if so, remove them
// this problem in FCKeditor 2.6.3; perhaps will be fixed in later versions
///////////////////////////

$matcher = preg_match("/^<p>.*<\/p>$/", trim($text));

if ($matcher == 1) {
// trim off those p tags!
$text = ltrim($text, "<p>"); $text = rtrim($text, "</p>");
}
return $text;
}

or more simply, remove the following line from search.php

// weed out extraneous P tags
$blurb = stripP($blurb);

Andrew

On Wed, Jan 14, 2009 at 2:28 PM, Reed, Jr., Dennis

Reed, Jr., Dennis

unread,
Jan 14, 2009, 2:43:25 PM1/14/09
to subjec...@googlegroups.com
Nice!! This should keep me busy for a while :)

jonathan_L

unread,
Oct 11, 2012, 12:10:58 PM10/11/12
to subjec...@googlegroups.com
Hi all,

Is there a way to implement the same solution (a search box like the admin version but for the users) in the version SubjectsPlus 1.0.1 ?

I tried some solutions but it is not working.

Thanks!

Andrew Darby

unread,
Oct 11, 2012, 3:19:26 PM10/11/12
to subjec...@googlegroups.com
Hi Jonathan,

Diane Z did this, and I have a slightly modified version of her work
that will get incorporated into the next version. Try out the
attached files. I can't promise they are error free, since I just
tinkered with them a bit . . .

Andrew
> --
> You received this message because you are subscribed to the Google Groups
> "SubjectsPlus" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/subjectsplus/-/cNs7EIiAbz0J.
> To post to this group, send email to subjec...@googlegroups.com.
> To unsubscribe from this group, send email to
> subjectsplus...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/subjectsplus?hl=en.
index.php
search.php
Reply all
Reply to author
Forward
0 new messages