hi,
1. i trying to make search on my site with wix code.
I had before the app Site Search.
i put the code exactly like
https://webixdesigns.wixsite.com/search-redirect/code
and
https://www.youtube.com/watch?v=Hx7_8-lRsW0 ==
2. in one section on my site that is in lightbox its work.
but I want from him to look at description as well on the product and not just his name, does anyone know how I add it? --- i try to do this >
function filter(title) {
if (lastFilterTitle !== title) {
$w('#dataset1').setFilter(wixData.filter().contains('name', title)).or(wixData.filter().contains('description', title));
lastFilterTitle = title;
}
}
3.On the second page it does not work
https://www.topink.co.il/results
import {local} from 'wix-storage';
import wixData from 'wix-data';
$w.onReady(function () {
var sameWord = local.getItem("searchWord");
$w("#searchBox").value = sameWord;
$w("#searchBox").placeholder = sameWord;
$w('#dataset1').onReady(function () {
search();
});
});
let lastFilterTitle;
let debounceTimer;
export function searchBox_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#searchBox').value);
}, 100);
}
function filter(title) {
if (lastFilterTitle !== title) {
$w('#dataset1').setFilter(wixData.filter().contains('name', title));
lastFilterTitle = title;
}
}
export function searchButton_click() {
search();
}
function search() {
wixData.query('Products')
.contains('name', $w("#searchBox").value)
.or(wixData.query('Products').contains('description', $w("#searchBox").value))
.find()
.then(res => {
$w('#searchRepeater').data = res.items;
});
}
i am need from the find products by ..contains('name') name and by .contains('description').
not or
Hi,
You can use the query function and use the contains and or WixDataQueries to find the relevant results.
Best,
Tal.
hi,
1. ok
2.I have website products that are printers and inkjet printers for example.
Each of them has a different name.
When a customer searches for printer ink he searches by the name of his printer.
In the ink product, the name of the printer appears in the description.
So when another customer searches for a printer, I want the ink to appear as well.
So I need to run a search for the name and description and present both.
3.I hope I understood you
Hi,
Please review the answers below:
1. There's no control on the speed loading time of your lightbox. You can try using a box instead (use the show and hide functions) which may be faster.
2. Do you wish to search for the exact string or part of a string that the user was typing? Can you please clarify what is the use case?
3. If you wish to redirect to a page, you should use the to function. Basically, on the code you provided you just set a value to the variable without doing any action.
Best,
Tal.
?
?
?
ok thanks it׳s work.
Some things I'm trying to accomplish
1. the filter search in "חיפוש" light box have faster and
2. also get search results from the description of the product in addition to there. For example someone is looking for a model of a printer so I want her ink spline to appear. In the ink product, the model of the printer is in the description
I tried to add
$w('#dataset1').setFilter(wixData.filter().contains('name', title).contains('description', title));
or in search result page
function search() { wixData.query("Stores/Products") .contains('name', $w("#searchBox").value)
.contains('description', $w("#searchBox").value) .find() .then(res => { $w('#searchRepeater').data = res.items; }) .catch(err => { console.log('err', err) }) }
In some ways but no way worked for me/
3. When you press the Enter key, it also moves to the search page.
i tried to add
$w('#searchBox').onKeyPress(event, $w) => { let key = event.key; }
and its not work
thanks your help
Hi!
Before I can help you to solve this issue I need some more information about your site.
Where other than the ״חיפוש״ LightBox do you use the search functionality?
Can you clarify what are you trying to achieve? (other than fix the search functionality in the second page)
As for the search itself. You cant use DataBinding (dataset use) and code on the same components.
In order for your search functionality to work you need to disable the dataset connections from all the components and present the data using code.
This code snippet should solve your issue (considering you did disable the dataset connections).
import { local } from 'wix-storage'; import wixData from 'wix-data'; $w.onReady(function () { $w('#searchRepeater').onItemReady(($w, itemData, index) => { $w('#image21').src = itemData.mainMedia; $w('#button29').link = itemData.productPageUrl; $w('#text64').text = itemData.name; }) var sameWord = local.getItem("searchWord"); $w("#searchBox").value = sameWord; $w("#searchBox").placeholder = sameWord; $w('#dataset1').onReady(function () { search(); }); }); let lastFilterTitle; let debounceTimer; export function searchBox_keyPress(event, $w) { if (debounceTimer) { clearTimeout(debounceTimer); debounceTimer = undefined; } debounceTimer = setTimeout(() => { filter($w('#searchBox').value); }, 100); } function filter(title) { if (lastFilterTitle !== title) { $w('#dataset1').setFilter(wixData.filter().contains('name', title)); lastFilterTitle = title; } } export function searchButton_click() { search(); } function search() { wixData.query("Stores/Products") .contains('name', $w("#searchBox").value) .find() .then(res => { $w('#searchRepeater').data = res.items; }) .catch(err => { console.log('err', err) }) }
Hope it helps.
Best of luck!
Doron.
?
?
?