Hello David
I am using tapestry for a special integration
i have a xml with more Index Fields than in tapestry by default
i saw a mod to add index fields so there should be no problem on this point ;)
actually there is no price in my feed but 4 index fields
one or two of these fields are filled, the others are empty
like this in xml :
<field_1_name></field_1_name>
<field_2_name></field_2_name>
<field_3_name></field_3_name>
<field_4_name>54</field_4_name>
in this example i would like tapestry to see that field 1 to 3 are empty and that field 4 is filled
in order to make appear on my site : field_4_name = 54
is it possible ?
Thank you very much for your help
cheers,
Coyote
hi David
and first thank you for your answer :)
Actually what i would like to do is :
add four optional index fields like brand or category existing by default
so that i can have pages with all products corresponding to each of these new fields (like category pages or brand pages)
how can i do that ?
Secondly, i want to make appear on each product page values of those 4 new fields, but only when they are given
for example :
if there is for one product :
<field_1_name></field_1_name>
<field_2_name></field_2_name>
<field_3_name></field_3_name>
<field_4_name>54</field_4_name>
then just give this information on the product page : field 4 name : 54
if there is for one product :
<field_1_name></field_1_name>
<field_2_name>36</field_2_name>
<field_3_name></field_3_name>
<field_4_name>54</field_4_name>
then just give this information on the product page :
field 2 name : 36
field 4 name : 54
i hope this is clear ;)
thank you for your help :)
Cheers
Coyote
Hello Coyote,
I understand - both are quite easy to do once you have added the new fields as per the instructions in this thread:
http://www.pricetapestry.com/node/313
> so that i can have pages with all products corresponding to each of
> these new fields (like category pages or brand pages)
Look in search.php for the following code (line 36 in the distribution):
case "merchant":
// pass through to category
case "category":
// pass through to brand
case "brand":
All you need to do is add a case statement for each of the new fields, like this:
case "field_1_name":
case "field_2_name":
case "merchant":
// pass through to category
case "category":
// pass through to brand
case "brand":
Then, you can link to all products with field_n_name of a certain value by using a search query like "field_n_name:value:", for example:
/search.php?q=field_1_name:some value:
(of course throughout using the actual field names)
> Secondly, i want to make appear on each product page values of
> those 4 new fields, but only when they are given
On the product page, i.e. anywhere within html/product.php, all fields are available in the $mainProduct array, for example:
$mainProduct["field_1_name"]
...so all you need to do is write code to display that field within an if statement to see if it contains a value. For example:
<?php
if ($mainProduct["field_1_name"])
{
print "<p>Field 1 Name: ".$mainProduct["field_1_name"]."</p>";
}
?>
Hope this helps!
Cheers,
David.
Hi David
Excellent, thank you so much, it works like a charm :)
only one detail :
with your :
[code]/search.php?q=field_1_name:some value:[/code]
it works with a specified value, but what i want is to have the list of products with field_x_name filled
as if field_x_name was a brand or a category and that all products in it would be listed
how can i do that
thank you again :)
Cheers,
Coyote
Hiya,
That's do-able - but just requires a separate section in search.php instead of using the existing code that supports the category/brand/merchant search.
Instead of the mod described above, add the following code at the same point - taking care to make sure that "break" appears at the end so that it doesn't fall through into other version...
case "field_1_name":
case "field_2_name":
$where = " ".$parts[0]."<>'' ";
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE ".$where." GROUP BY name";
$sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE ".$where;
$orderBySelection = $orderByDefault;
break;
Now, simply link with:
/search.php?q=field_1_value:
Cheers,
David.
Works like a charm, thank you David ;)
The last thing i want to settle is a advanced search page :
First question, the default search box is only searching in the products names, true ? if so, would it be possible to make it search in products descriptions rather ?
Second question, for my advanced search page i would like more precisely :
the normal search box if no criteria is checked
and the possibility to add criterias, i.e searching only in products taking part of field_1_name or field_e_name etc or category x etc
so one field OR some fields checked
that means also the possibility to search products taking part of field_1_name AND category x AND brand y for example
how could i do that
i saw this mod : http://www.pricetapestry.com/node/1478 to search by category, i suppose it should be a start for this...
Thank you very much for your help
Cheers,
Coyote
Hi,
Have you come across the following thread for modifying the index / search to incorporate the description....
http://www.pricetapestry.com/node/1224
Creating an advanced search is quite a lot of code as it requires a new section in search.php to handle multiple inputs, and then modifications to ensure that all the fields are propagated onto the subsequent pages (2,3 etc.)
Are you comfortable with creating HTML forms? The first step is to create the form that would submit to search.php, but with a box for each of the fields you want to search (let me know if you need help here...) then i'll work through the changes in search.php with you...
Cheers,
David.
Hi David
Thank you for the fulltext mod, it works perfectly ;)
For the form, i think about this kind of one :
<form name="search" method="post" action="search.php" target="_top" onsubmit="">
<span class="look">Your search :</span>
<input type='text' name="q" id="keywords" class="text"/>
<input type="checkbox" name="category" value="1"> name 1
<input type="checkbox" name="category" value="2"> name 2
<input type="checkbox" name="category" value="3"> name 3
<input type="checkbox" name="category" value="4"> name 4
<input type="checkbox" name="category" value="5"> name 5
<input type="checkbox" name="index_field_x" value="1"> title 1
<input type="checkbox" name="index_field_x" value="2"> title 2
<input type="checkbox" name="index_field_x" value="3"> title 3
<input type="checkbox" name="index_field_x" value="4"> title 4
<input type="checkbox" name="index_field_x" value="5"> title 5
<input type="submit" value='Ok'>
</form>
If no button is checked, it will search everywhere by default, if some boxes are checked, then it limits the search to the field(s) checked
checkbox seems to be the right solution as people may choose several categories to perform their search for instance...
Thank you for your help, this is the last step for me :)
Cheers,
Coyote
Hello Coyote,
This is actually quite easy to do; but involves lots and lots of minor changes! I think what would be easier that modifying search.php to handle this would be to create a new advancedSearch.php script. If you could email me (reply to your reg code or forum registration email) your current versions of search.php and html/navigation.php i'll edit these inline with the form HTML shown above (although there may need to be slight changes to that)...
Cheers,
David.
Hello David
thank you for your nice help :)
here is a little bit more precise form :
<form name="search" method="post" action="search.php" target="_top" onsubmit="">
<span class="look">Your search :</span>
<input type='text' name="q" id="keywords" class="text"/>
<input type="checkbox" name="category" value="c1"> name 1
<input type="checkbox" name="category" value="c2"> name 2
<input type="checkbox" name="category" value="c3"> name 3
<input type="checkbox" name="merchant" value="m1"> name 1
<input type="checkbox" name="merchant" value="m2"> name 2
<input type="checkbox" name="merchant" value="m3"> name 3
<input type="checkbox" name="field_1_name" value="f1"> title 1
<input type="checkbox" name="field_2_name" value="f2"> title 2
<input type="checkbox" name="field_3_name" value="f3"> title 3
<input type="submit" value='Ok'>
</form>
the field_x_names correspond to the new index fields i created as you told me (see last discussions of this topic)
I send you my search.php and navigation.php
Thank you
Cheers,
Coyote
hi David
Just a word to check if you received my email or not
i sent it to you from coyotelex @ gmail.com
Cheers,
Coyote
Hi Coyote,
Yes - thanks for the files, bear with me and i'll get back to you with an advanced search script based on your form...
Cheers,
David.
Hello Coyote,
Would it be an option to register field_1_name (as required - either an existing field or one of your new ones); and then use the Text After filter to append the value of each of the other field_n_name elements, combining them into a single value?
You can pull in the value of other fields using the %FIELDNAME% placeholders in the text box on the configuration page for a Text After filter, so for example, you could use:
%FIELD_2_NAME% %FIELD_3_NAME% %FIELD_4_NAME%
This would mean that whichever field the value was in, it would appear as the value of the combined field...
Cheers,
David.