Our store sells t-shirts from various anime series. Right now, we have over 300 series, so creating categories through x-cart was becoming a bother. Instead of having to create a new category every time we wanted to add a product from a new series, I figured it would be easier to just have param00 to be the name of the series, and write a script to automatically generate a list of the series names in the database. Some of the series names have apostrophes (') in them, so to handle this I added a line
Quote:
$substring=addslashes($substring);
|
to the beginning of customer/search.php.
To get the listing of all the series,
I created a file customer/series.php
Quote:
<?
#
# $Id: series.php,v 1.43 2002/11/14 07:58:18 zorg Exp $
#
#
# Select distinct Series from param00
#
$series = func_query("SELECT DISTINCT param00 FROM $sql_tbl[products]");
sort($series);
#
# Assign Smarty variables
#
$smarty->assign("series",$series);
?>
|
and I added a new template, customer/series.tpl with the following code:
Quote:
{* $Id: series.tpl,v 1.16 2002/10/21 07:06:43 zorg Exp $ *}
<TABLE border=0 cellPadding=5 cellSpacing=0 width=100%>
<TR>
<TD class=VertMenuTitle height=26 width=26 valign=center>[img]{$ImagesDir}/dingbats_categorie.gif[/img]</TD>
<TD class=VertMenuTitle height=26 valign=center width="80%"><FONT class=VertMenuTitle>{$lng.lbl_series}</FONT></TD>
</TR>
<tr><td colspan=2 nowrap>
{section name=series_list loop=$series}
<a href="http://animegination.com/xcart/customer/searchseries.php?substring={$series[series_list].param00}">
<font class=CategoriesList>
{ $series[series_list].param00}</a></font>
{/section}
</td></tr>
</TABLE>
|
(searchseries.php is the same as search.php except it searches param00 for the exact string)
I then modified customer/home.tpl so that the new series list would show up on the main page.
Now all of this works great: all of the series in the database are listed on the main page, and when you click on the name of a series it will return all of the products in that series.
There are two small problems, though.
1. The series are listed on the main page, but once you click on the name of a series (and when you are on other miscellaneous parts of the website), the series are no longer listed on the side.
2. When you enter a series name with an apostrophe in it into the search box, it will find the series without error, and properly formats the url. When you click on a one of the listed series names that has an apostrophe in it, however, it will return the same products, but comes up with the error
Quote:
INVALID SQL: 1064 : You have an error in your SQL syntax near 's%20High%20Kick'' at line 1
SQL QUERY FAILURE: SELECT pageid FROM xcart_stats_pages WHERE page='/xcart/customer/searchseries.php?substring=Ayane's%20High%20Kick'
|
at the top. I have a feeling it is because of the way I am passing the substring variable to the search script, but can't think of a way to fix it.
I would appreciate any help with this problem; it feels like there is just something stupid that I am overlooking. Hopefully this long post hasn't scared you away! I think this is a neat, fairly simple mod, so if I can get it working, hopefully others can benefit from it too. If you want to see the mod and the problems I was describing, head on over to
http://www.animegination.com , but be warned that despite some issues, it is still a live site!