Hi David,
Looking to normalise my "author" field which has been added to my database. Also have an authors.php file which is just a copy of categories.php, and would like to change
$config_baseHREF."author/".tapestry_hyphenate($product["author"])."/";
to
$config_baseHREF."author/".tapestry_hyphenate($product["normalised_author"])."/";
Was looking at the code and see that the normalise function is created in included/admin.php
/* create normalised version of product name for use in URLs */
$normalisedName = tapestry_normalise($importRecord["name"]);
and also other references in this file.
Can you describe what should code should be added to get this working.
Many thanks
Adrian
Hi Adrian,
First stage of course is to add the normalised_author field to your database - VARCHAR(255) as per the other fields.
With that in place; pretty much just duplicate the code within the import record handler function in includes/admin.php, so after the following line (that you have already identified):
$normalisedName = tapestry_normalise($importRecord["name"]);
add:
$normalisedAuthor = tapestry_normalise($importRecord["author"]);
...and then within the SQL (around about line 317)
normalised_name='%s',
...add:
normalised_author='%s',
...and finally after:
database_safe($normalisedName),
...add:
database_safe($normalisedAuthor),
You would then need to modify search.php so that the normalised version of author is searched instead of the display version. To do this, in your search.php (based on the last version I sent you), look for the following code on line 107:
$where .= " ".$field." = '".database_safe($parts[$i])."' ";
...and REPLACE with:
if ($field == "author") $field = "normalised_author";
$where .= " ".$field." = '".database_safe($parts[$i])."' ";
...and that should do the trick!
Cheers,
David.