1. A way to record every search made
Requirements
a/ A new DB table to be created to store the searches.
b/ A way to insert relevant data into the new DB table.
Seems straightforward.
--
A.
Now it's time to think about the structure of the new DB table;
Some things are obvious;
Search ID - just an auto-incremented number for each "record" in the DB
Search String - what someone searched for
Date of Search - might be useful I guess?
Status - 0 or 1 as shopowner might not want some searches to show shop side
What else could we add?
Language - it might be nice to record the language ID
With this in mind, we know we have to somehow count searches. I can think of two ways to do this;
1. Add records to the DB and "count" as part of the SQL call
2. Have a counter in the DB and simply increase the counter if the search term has already been searched for
I like the idea of #2 as it would be more interesting to code. I now know I need to have a;
counter - which increments as people search for the same thing
Already a potential problem
If we have the counter this way, we need to determine that (for example) a search for (eg) "shiny" is the same as a search for (eg) "Shiny". Note the difference as one is capitalised, the other not. Basically we don't want both "shiny" and "Shiny" to be shown in the eventual Tag Cloud. I'll think about that.
B.
For recording the searches into the DB, I'm thinking a simple Hook will do the job. If there is no suitable hook listener I can easily add a Hook by overriding the advanced_search_result page. That is really simple, but obviously needs the DB table to be created in the structure that I decide on.
Put simply, it's the structure of the DB that is the most important right now - everything else comes from that.