Hello David,
I'm using PT and Wordpress together and I'm trying to design a site that off course looks good and allows me to blog and offer products at the same time. I'm having some difficulty you can perhaps help me with. I got these questions:
Can I amend the sidebar filter in such a way that the "By Category" section shows the categories that have been collected inside a category map?
When importing feeds and thousands of products categories tend to get a mess as each merchant seems to have their own categories. Tidying up by category mapping and subcategories would be the answer. I know PT doesnt support subcategories, but perhaps you have a mod for the sidebar filter that does the above mentioned which would solve this problem?
And about the sidebar filter, can I add more options to that? Things like size, or color which are column headers that are also often found inside a feed?
Where do I start to translate the Pricetapstry files when using the plugin for Wordpress. Do I need to translate the plugin files or the HTML files of Pricetapstry itself? I tried the latter but it didnt seem to have any effect. Refreshing my cache didnt work either so I must be doing something wrong. I thought I'd just ask you where to start, instead of spending hours looking for it myself.
In some Wordpress themes the Prices table becomes very small or the photos in the categories become very small. How can I set default sizes for both so they stay the right size regardless of the theme I use? And to that extend, is there a Wordpress theme you recommend that does right to all aspects of Pricetapestry? As mentiond I'm having a hard time finding a theme that does not shrink photos, tables of reduces category columns to 2 instead of 3 or 4. One theme leaves the photo's alone but messes up the category columns, while an other theme does the columns right but shrinks the prices table. Any suggestions?
I hope you can help with this.
Regards
Robert
Thanks a lot for the quick answer David!
A got a lot to do the coming days it seems.
Cheers!
Robert
OK David, I think Im not understanding you completely when it comes to adding another filter to the sidebar.
I opend up html/searchresults.php and you want me to copy that big block of code where exactly, at which line?
And when I open up search.php line 16 reads:
$minPrice = sprintf("%.2f",$_GET["minPrice"]);
You want me to place the code underneath on line 17? And then the rest.
$colorFilter = ($_GET["colorFilter"]?$_GET["colorFilter"]:"");
Would you mind if we take a real live example?
When you look at this page:
{link saved}
I would like to add a filter for region to the sidebar. The way it is now "Op reisagent" Filters Merchant, "Op bestemming" filters country, "Soort accomodatie" filters accomodation type, and now I want to add a filter that is called "Op regio" and that filters on region.
Can you tell me step by step what to do? Dont worry if I can get it working once I can do it on all my sites so I wont have to take up too much of your time after this.
Regards,
Robert
Hello Robert,
Ah my apologies, I had assumed that you had already installed the sidebar filters versions of search.php and html/searchresults.php.
You can download these from this page (SidebarFilters.zip) and with those in place the above will make more sense!
Cheers,
David.
--
PriceTapestry.com
Ok David, now it makes sense, and I managed to complete that. I figured I also needed to amend the sidebar widget code in the pricetapestry options page within Wordpress. So I added a piece of code by replicating the section on brands. The thing is if I amend anything there the code just ends up on the page instead of it being put to work.
This is the piece I put in:
%IF_REGION%
<br />Regio:
<br /><select name='pto_regioFilter'>
<option value=''>Alles</option>
%REGION%
</select>
%ENDIF_REGION%
And see how it ends up in the sidebar:
{link saved}
Any idea as to why that is?
Cheers
Robert
Hi Robert,
Sounds like you're almost there; the only remaining modification would be to duplicate the code that handles the %IF_REGION%....%ENDIF_REGION% placeholders.
You'll find the equivalent section for %IF_BRAND% in pto_search.php beginning at line 894 with:
$sql = "SELECT DISTINCT(brand) FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$pto_searchWhere." AND brand <> '' ORDER BY brand";
...and ending with:
else
{
$html = preg_replace('/%IF_BRANDS%(.*)%ENDIF_BRANDS%/','',$html);
}
...at line 913. Duplicate the above with the appropriate replacements for REGION/region (make sure to copy case exactly) and that should be all it is...
Cheers,
David.
--
PriceTapestry.com
Almost there indeed, because now I want to register the feed and import the region column also. And the category and brand are allready taken up bij country column and accomodation. Guess when I'll complete the region mod, I'll just mod everything by there proper name.
Can you tell me where and how to amend the import feed page?
Regards,
Robert
Hi Robert,
Shouldn't need anything more than the standard extra field mods described in this thread...
Make sure that the name you use is consistent with mods you have already made; so in this case you'll be adding field_region to the `feeds` table and region to the `products` table...
Cheers,
David.
--
PriceTapestry.com
Allright did all that. Imported my feeds again but the filters don't seem to function. They are there, there is data in the new sidebar filters, but using the filters doesnt seem to change the search results. I've retraced my steps a few times, but I cant seem to find where I went wrong. Any suggestions?
Hi Robert,
Sounds like it's almost there, but I think there is still some duplication of the brandFilter (which I know is the code instance that you have been duplicating).
Check through
pto.php
and
pto_search.php
...for each instance of brandFilter (use the Search function of your text editor) and check that you have equivalent code for regionFilter in place - that should be all it is;
Cheers,
David.
--
PriceTapestry.com
Fantastic! That was it, it works like a charm now. Thanks David!
Oh one more question. I added the filters region and city tot the sidebar filter. But is it possible to have the contents of these filters be dependent on the country choice a user makes? Otherwise they start combining countries and cities that do not belong to each other and they get no results. Is that do-able or would that mean overhauling every mod we just made again?
Hi Robert,
By default the filters apply to the original query - you'll see in how the SQL to derive each filter uses just $where; however you can make the filters "accumulative" by appending $priceWhere to the WHERE clause; in your sidebar filters version of html/searchresults.php search for:
$where
...and REPLACE with:
$where.$priceWhere
Cheers,
David.
--
PriceTapestry.com
That seems to work when somebody clicks on a link to a specific category (country). Then only the regions and cities of that country are in the sidebar filter. But when a visitor clicks a link to all merchants who have the same brand then multiple countries and every city or region can be combined. It then becomes more of a geography test then a hunt for a fun vacation resort.
See example:
{link saved}
Is there perhaps a way to have the contents of region and city refresh with the proper contents as soon as some one for instance chooses Great Britain as a destination? Otherwise I would have to think of some kind of workaround. I foresee a lot of visitors combining wrong data and getting no results. From the statistics this morning I saw that a few affiliate companies who are approving my site already ran into trouble.
Regards
Robert
Hi Robert,
Sure - the drop-downs can be made auto-submit quite easily. In your html/searchresults.php, look for the following code where the <form> tag is opened:
print "<form method='GET' action='".$config_baseHREF."search.php'>";
...and REPLACE with:
print "<form id='filters' method='GET' action='".$config_baseHREF."search.php'>";
Next, for each of the <select .... tags, insert an onChange event handler as follows:
onChange='JavaScript:document.getElementById(\"filters\").submit();'
...so for the merchantFilter, you would replace line 27:
print "<select style='width:150px;' id='mf' name='merchantFilter'>";
with:
print "<select onChange='JavaScript:document.getElementById(\"filters\").submit();' style='width:150px;' id='mf' name='merchantFilter'>";
(similar of course for the other drop-downs)
To tidy things up; you can then make the Apply button only show if JavaScript is not enabled by replacing
print "<input type='submit' value='Apply' />";
with:
print "<noscript><input type='submit' value='Apply' /></noscript>";
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Ok David, I did all that. Do I need to change anything to the sidebar code in Wordpress PT settings? Because I dont really see a change yet.
Hello Robert,
Could you post an example URL; I'll check the full source out, it is possible there could be conflict with other JavaScript code on the page...
(i'll remove the link before publishing your reply)
Cheers,
David.
--
PriceTapestry.com
Hi Robert,
Ah sorry, the equivalent JavaScript interaction mods needs to be made to the plugin HTML for the sidebar filters. This can all be added through the HTML templates in wp-admin > Plugins > PriceTapestry.org. Scroll down to Main > Search Filters Widget. Here you'll find:
<form method='GET' action='%ACTION%'>
...REPLACE with:
<form id='filters' method='GET' action='%ACTION%'>
And also each <select ... boxes, so as before add to each one
onChange='JavaScript:document.getElementById("filters").submit();'
...and also the Apply button:
<input type='submit' value='Apply' />
...REPLACE with:
<noscript><input type='submit' value='Apply' /></noscript>
Cheers,
David.
--
PriceTapestry.com
OK so
<select name='pto_merchantFilter'>
becomes
<select onChange='JavaScript:document.getElementById(\"filters\").submit();'name='pto_merchantFilter'>
right?
The whole code now is:
<div class='pto_search_filters_widget'>
<form id='filters' method='GET' action='%ACTION%'>
<input type='hidden' name='pto_q' value='%PTO_Q%' />
%IF_MERCHANTS%
Op reisagent:
<br /><select onChange='JavaScript:document.getElementById(\"filters\").submit();'name='pto_merchantFilter'>
<option value=''>Alles</option>
%MERCHANTS%
</select>
%ENDIF_MERCHANTS%
%IF_CATEGORIES%
<br />Op bestemming:
<br /><select onChange='JavaScript:document.getElementById(\"filters\").submit();'name='pto_categoryFilter'>
<option value=''>Alles</option>
%CATEGORIES%
</select>
%ENDIF_CATEGORIES%
%IF_BRANDS%
<br />Soort accomodatie:
<br /><select onChange='JavaScript:document.getElementById(\"filters\").submit();'name='pto_brandFilter'>
<option value=''>Alles</option>
%BRANDS%
</select>
%ENDIF_BRANDS%
%IF_REGION%
<br />Regio:
<br /><select onChange='JavaScript:document.getElementById(\"filters\").submit();'name='pto_regionFilter'>
<option value=''>Alles</option>
%REGION%
</select>
%ENDIF_REGION%
%IF_CITY%
<br />Stad:
<br /><select onChange='JavaScript:document.getElementById(\"filters\").submit();'name='pto_cityFilter'>
<option value=''>Alles</option>
%CITY%
</select>
%ENDIF_CITY%
<br />Op prijshoogte:
<br />
<input type='text' size='4' name='pto_minPrice' value='%PTO_MINPRICE%' />
tot
<input type='text' size='4' name='pto_maxPrice' value='%PTO_MAXPRICE%' />
<br />
<noscript><input type='submit' value='Apply' /></noscript>
</form>
</div>
I can select all fields but nothing happens I'm afraid. The filter is not refreshing, only the apply button is gone.
Hi Robert,
Nearly there - I'd left the escape characters in in-front of each " character which is a PHP specific requirement and not requirement in standard HTML (which is what the templates are). Also make sure that there is white space between the closing ' of each attribute. Strictly speaking this shouldn't be necessary but it's good practice for maximum browser compatibility - just in case! Have a go with:
<div class='pto_search_filters_widget'>
<form id='filters' method='GET' action='%ACTION%'>
<input type='hidden' name='pto_q' value='%PTO_Q%' />
%IF_MERCHANTS%
Op reisagent:
<br /><select onChange='JavaScript:document.getElementById("filters").submit(); 'name='pto_merchantFilter'>
<option value=''>Alles</option>
%MERCHANTS%
</select>
%ENDIF_MERCHANTS%
%IF_CATEGORIES%
<br />Op bestemming:
<br /><select onChange='JavaScript:document.getElementById("filters").submit(); 'name='pto_categoryFilter'>
<option value=''>Alles</option>
%CATEGORIES%
</select>
%ENDIF_CATEGORIES%
%IF_BRANDS%
<br />Soort accomodatie:
<br /><select onChange='JavaScript:document.getElementById("filters").submit(); 'name='pto_brandFilter'>
<option value=''>Alles</option>
%BRANDS%
</select>
%ENDIF_BRANDS%
%IF_REGION%
<br />Regio:
<br /><select onChange='JavaScript:document.getElementById("filters").submit(); 'name='pto_regionFilter'>
<option value=''>Alles</option>
%REGION%
</select>
%ENDIF_REGION%
%IF_CITY%
<br />Stad:
<br /><select onChange='JavaScript:document.getElementById("filters").submit(); 'name='pto_cityFilter'>
<option value=''>Alles</option>
%CITY%
</select>
%ENDIF_CITY%
<br />Op prijshoogte:
<br />
<input type='text' size='4' name='pto_minPrice' value='%PTO_MINPRICE%' />
tot
<input type='text' size='4' name='pto_maxPrice' value='%PTO_MAXPRICE%' />
<br />
<noscript><input type='submit' value='Apply' /></noscript>
</form>
</div>
Cheers,
David.
--
PriceTapestry.com
Spot on David! Thanks very much for your great support!
Hi Robert,
Sure - the sidebar filters Category drop down could be restricted to mapped categories only as follows. In the sidebar filter code (modified version of html/searchresults.php look for the following code:
$sql1 = "SELECT DISTINCT(category) FROM `".$config_databaseTablePrefix."products` WHERE ".$where." AND category <> '' ORDER BY category";
...and REPLACE with:
$sql1 = "SELECT DISTINCT(category) FROM `".$config_databaseTablePrefix."products` WHERE ".$where." AND category <> '' AND category IN (SELECT name FROM `".$config_databaseTablePrefix."categories`) ORDER BY category";
Additional filters can be added to the sidebar, it's basically just a case of copying the filter section in html/searchresults.php, so for example to add a filter on the new field "color" you would use:
$sql1 = "SELECT DISTINCT(color) FROM `".$config_databaseTablePrefix."products` WHERE ".$where." AND color <> '' ORDER BY color";
if (database_querySelect($sql1,$rows1))
{
print "<label form='cf'>By color:</label><br />";
print "<select style='width:150px;' id='cf' name='colorFilter'>";
print "<option value=''>All</option>";
foreach($rows1 as $row)
{
$selected = ($_GET["colorFilter"]==$row["color"]?"selected='selected'":"");
print "<option value='".htmlentities($row["color"],ENT_QUOTES,$config_charset)."' ".$selected.">".$row["color"]."</option>";
}
print "</select>";
print "<br /><br />";
}
And in search.php search for each instance of "categoryFilter" and replicate the code for "colorFilter", so this would be...
after line 16:
$colorFilter = ($_GET["colorFilter"]?$_GET["colorFilter"]:"");
after line 60:
if ($colorFilter)
{
$priceWhere .= " AND color = '".database_safe($colorFilter)."' ";
}
after line 320:
if ($colorFilter)
{
$sortHREF .= "colorFilter=".urlencode($colorFilter)."&";
}
and finally after line 413:
if ($colorFilter)
{
$sort .= "&colorFilter=".urlencode($colorFilter);
}
Regarding translation; the content generated by the plugin is entirely down to the HTML templates in the configuration at wp-admin > Settings > PriceTapestry.org, so there's no files that require editing at all; the Price Tapestry files themselves aren't used at all in the invocation of plugin generated content.
Regarding the theme, I have designed the distribution against the default WordPress theme Twenty Eleven, however all content generated by the plugin is classed so any styles being applied by your theme at a higher level can be overridden by the appropriate modification in wp-content/plugins/pto/resources/pto.css. If you're not sure which class to modify or add; check the HTML templates in wp-admin > Settings > PriceTapestry.org; for example to increase the price comparison table width to 100%, you could add:
.pto_prices table {
width: 100%;
}
Likewise for the A-Z output (Merchant, Category & Brand lists) you could add:
.pto_atoz table {
width: 100%;
}
Note that setting a width of 100% is 100% of the parent container, so if the above examples don't have a noticeable impact check the post body styling in your theme - if you're not sure what to change feel free to post a link to an example (I'll remove before publishing) and I'll check the HTML being generated...
Cheers,
David.
--
PriceTapestry.com