DISCLAIMER: This should be tested on a development environment that is close to or the same as your production environment. Some of the mechanisms used here will not work in all server configurations. I will take any feedback and try to make it compatible with all setups.
Download
Download latest version: ct-community-college-course-search-latest.zip
Description
This Wordpress plugin lets you add two types of course search engines on your website: a quick search and a custom search. Either one, or both, can be added with some simple shortcodes. The great part about the custom search is that each field is added with a different shortcode, so you can lay out the form how you like.
This plugin only searches the CT Community College system website for courses.
I built this modularly so you can implement only what you want on your site. There are two distinct components – the quick search and the custom/advanced search.
Quick Search
Option 1: Single Term (search only one term)
To implement this:
- install the plugin
- add the search form shortcode to a page:
[ccccs-course-search-basic term=1173]
note: change the term parameter from 1173 to the one you want to search*. - on the same page, probably further down, add the results shortcode:
[ccccs-course-results-basic term=1173]
again, change the term parameter to match the previous.
* you can find term parameter codes by inspecting the HTML of the term select box on online.commnet.edu, or just ask me for some guidance here.
Option 2a: Top x Terms (a dropdown lets the user pick a term before running a quick search)
Demo: https://www.tunxis.edu/course-search/ (the first search area on the page)
To implement this:
- install the plugin
- add the search form shortcode to a page:
[ccccs-course-search-basic term=top count=3]
note: change the count parameter from 3 to the number of terms you want available (starts at most recent)*. - on the same page, probably further down, add the results shortcode:
[ccccs-course-results-basic term=top]
Option 2b: Specific Terms (a dropdown lets the user pick a term before running a quick search)
To implement this:
- install the plugin
- add the search form shortcode to a page:
[ccccs-course-search-basic term="1173,1181"]
note: change the term parameter to a list of term codes you want available*. - on the same page, probably further down, add the results shortcode:
[ccccs-course-results-basic term=top]
* you can find term parameter codes by inspecting the HTML of the term select box on online.commnet.edu, or just ask me for some guidance here.
Custom Search
Demo:
https://www.tunxis.edu/course-search/ (the second search area on the page)
To implement this:
- install the plugin
- add appropriate search field shortcodes to a page (see ccccs shortcode reference)
- on the same page, probably further down, add the results shortcode:
[ccccs-course-results-advanced]
- add the class
search-code-advanced
to an HTML element (probably adiv
) which wraps the entire set of search field shortcodes
Shortcode Reference
// --- quick search ---> [ccccs-course-search-basic term="1173|1173,1181,...|top" [count=3]] [ccccs-course-results-basic term="1173|top"] // --- custom search ---> [ccccs-course-search-advanced field=sel_subj tag=select id=major label="Subjects"] [ccccs-course-search-advanced field=TERM tag=select id=term label="Semester"] [ccccs-course-search-advanced field=College_code tag=select id=college label="College"] [ccccs-course-search-advanced field=sel_title tag=input id=major label="Course Title (optional)"] [ccccs-course-search-advanced field=sel_schd tag=select label="Course Type"] [ccccs-course-search-advanced field=sel_open tag=input id=open label="Open"] [ccccs-course-search-advanced field=sel_open tag=input id=open label="Closed"] [ccccs-course-search-advanced field=sel_open tag=input id=open label="Both"] [ccccs-course-search-advanced field=sel_level tag=input id=level-credit label="Credit"] [ccccs-course-search-advanced field=sel_level tag=input id=level-noncredit label="Non-credit"] [ccccs-course-search-advanced field=sel_level tag=input id=level-both label="Both"] [ccccs-course-search-advanced field=begin_hh tag=select id=class-type label="Hour"] [ccccs-course-search-advanced field=begin_mi tag=select id=class-type label="Minute"] [ccccs-course-search-advanced field=begin_ap tag=select id=class-type label="AM/PM"] [ccccs-course-search-advanced field=end_hh tag=select id=class-type label="Hour"] [ccccs-course-search-advanced field=end_mi tag=select id=class-type label="Minute"] [ccccs-course-search-advanced field=end_ap tag=select id=class-type label="AM/PM"] [ccccs-course-search-advanced field=sel_day type=checkbox tag=input label="Monday"] [ccccs-course-search-advanced field=sel_day type=checkbox tag=input label="Tuesday"] [ccccs-course-search-advanced field=sel_day type=checkbox tag=input label="Wednesday"] [ccccs-course-search-advanced field=sel_day type=checkbox tag=input label="Thursday"] [ccccs-course-search-advanced field=sel_day type=checkbox tag=input label="Friday"] [ccccs-course-search-advanced field=sel_day type=checkbox tag=input label="Saturday"] [ccccs-course-search-advanced field=sel_day type=checkbox tag=input label="Sunday"] [ccccs-course-search-advanced submit="Search"] // [ccccs-course-results-advanced] // --- NOTE: you MUST add the class "course-search-advanced" to a wrapper (cannot be a form tag) that goes around all of the advanced search fields. Do not put the [ccccs-course-results-advanced] shortcode into this wrapper. -->
Other Notes
The code is GPL2.0 so you can take it, modify it, port it to other languages or CMS’s as you like. The only requirement is that the code stay free and publicly accessible.
Core Features:
- Keep users on your site for running searches
- Style-free … so it will inherit the styles of your theme, or you can write/add your own flavor to the search form or results.
- Automagically searches your college’s courses … it uses the host domain to figure out which college results to return
- Mobile-friendly results – when long table rows won’t fit, it stacks table cells within a row so all returned data is still visible. If you prefer to allow horizontal scrolling, a few additional CSS styles can be applied to do that instead.
- Modular – use quick search, custom search, or both wherever you like. Fields of custom search are also quite configurable.
Core Features of Quick Search:
- FAST – it caches a complete listing of courses for your college on your site. It is set up to update once cached entries are > 20 minutes old.
- Finds search term in any text of a course listing, including course code, CRN, title, instructor name, etc.
- Can be set up with cron job so that search results are always cached and ready to be searched. If you don’t set up cron, then the page automatically tries to fetch the listing as soon as someone hits the page.
- Multiple quick search forms and results can be on a page. That means you can set up multiple quick searches within accordion sections or any UI component.
Core Features of Custom Search:
- Organize/display fields however you see fit, in any order. You can even omit fields.
- Always up-to-date – it actually copies the fields from the online.commnet.edu website on the fly, so you won’t need to update the term selection box when a new semester’s courses are available on the main site
Changelog
= 1.1.2 = * added nolo_crse variable to query with default value of 2 to satisfy search result requirements on remote server = 1.1.1 = * fixed something ... not sure what = 1.1.0 = * added ability to quick search multiple terms with one form (thanks for the idea Kristian C!) = 1.0.2 = * fixed something = 1.0.1 = * added code to select default college based on host domain = 1.0.0 = * initial release
@TODO
- add college code param to quick search tags just in case plugin is NOT hosted on a CT community college site (currently javascript just picks a college to search based on host domain)
- try to auto-wrap the advanced search fields
- add shortcodes for opening/closing tag of advanced form so that implementation does not require adding custom classes
- more error handling and checks for when data is not returned from main site
- simplify the advanced search field shortcodes or at least make some shortcuts to typing them in (they’re really long right now)
- do we really want to pull then entire form just to get the fields from online.commnet.edu? might be easier just to hard-code them and expect that we’ll update plugin code as needed
- make it so that user can choose to have a multi-select be an array of checkboxes instead of the default select elements