Website SearchAdding Search Capabilities to Site |
5
Summary
Development of the database objects and PHPServer-side scripting language for web development. classes to support site search functionality.
Overview
Purpose | To add search capabilities to web site. |
Goals |
|
Technology | No new additions to environment. |
Resources | None |
Implementation
Create Database Objects
The implementation of the below objects was done using PhinxA PHP library to automate the implementation of database changes. in a new migration created for this project.
- FACT_SEARCH - is a table was created to hold all the unique words in each page and the number of times each word appeared on the page.
- SEARCH_PURGE - a procedure that deletes all the rows in the Search table.
- SEARCH_INSERT - a procedure responsible for inserting records into the Search table.
Create \ Modify Controller Classes
- App/Controllers/Support/Utility.php - This class was modified to add three methods related the manipulation of multi-dimensional arrays.
- App/Controllers/Search.php - This class was created to manage the loading of the statistics data to FACT_SEARCH as wells as controlling the behavior of search requests.
Create Model Class
App/Models/Search.php - was created to interact directly with the FACT_SEARCH table allowing it to be reloaded and queried.
Create \ Modify View Files
- App/Views/Search/index.html - was created to display the search form and results of the search.
- App/Views/Admin/index.html - was modified to make the Search statistics reload method available via the site to admin users.
- App/Views/base.html - was modified to make the search option available on all pages from the navigation bar.
Add Search Controller to Dependency Injection Pattern
- public/index.php - modified to instantiate s shared Search Controller object which is injected into the Router.
- Core/Router.php - the constructor was modified to accept the Search object and pass it into Controller classes.
- Core/Controller.php - the constructor was modified to accept the Search object.
Populate Search Statistics
Login as admin and execute the Search load process from the Admin page.