top of page
LOGO
SendZoomFree Demo

Add Search Function to Your Repeater

Writer: CD Studio .
CD Studio .
Nov 16, 2023
3 min read

If you've been navigating the intricacies of Wix, you'll appreciate the power of repeaters in displaying dynamic content seamlessly. Now, imagine taking this functionality a step further by adding a search feature to your repeater. This simple yet transformative addition can elevate the usability of your website, making content retrieval swift and user-friendly. In this blog, we'll guide you through the process of integrating a search functionality into your Wix repeater, unlocking a new realm of efficiency for both you and your site visitors.


Search data in Repeater


Prerequisite:

Before you start this tutorial, you need to create a Wix site and design a repeater


Step 1: Enable CMS (Formerly Known as Content Manager)


O


To be able to search data to a repeater , all the data must be in the CMS. For that, you need to enable CMS.


From the left side of the editor, select CMS Which is selected in the image.

After, adding CMS to the site, Add a collection (it's like a table in a database).



You can create a collection in two ways:


  • Select the CMS icon from the left window panel as you did in the last step, then click on Create Collection

  • Or, Click on Add Element > CMS > Create Collection






Name your collection, for example, I gave "datasearch". Then click on Create.



Click on the "Title" Field > Edit to Edit your field name. I named it "Author's Name" .






Adding Image Field



You can Add images


Click on "Add field" (On the right side of the Title field) to Add other fields to the collection.


Now I am adding another field named 'image".

Here, the field type is kept as image.


Adding Description Field


Add other fields to the collection.


Now I am adding another field named 'Description".



After adding the fields, you can add the contents you want here. (You can always edit content later)


If you want you can add more fields to categorize.




In order to connect the elements on your page with the content in your CMS, you have to add a dataset to the page (it will be invisible in the published website).


Add element > CMS > Dataset





Once you inserted the dataset click on it and select the settings.













Then Select Your Collection,

here I selected datasearch.




After you configure the dataset, click on the repeater, and from the options click on "Connect to CMS".

After the last step, Below the dropdown, you can see the Elements section, Click on each element and connect it to the relevant fields.




Click on Image



Select the "Image source connects to" to the Image field








Likewise, connect other elements to the respective fields.









Now your Repeater should be populated with data from your CMS

To configure the buttons, we need to enable "Dev Mode" in order to write a few lines of simple code.



On the top left of the window hover over Dev mode.


Then click on Turn on Developer Mode

Following better coding standards, it is good to rename the 'id' of the elements, in this case, our elements are




search Author Name: #input1

dataset: #dataset1

database Fieldname: Author's Name

field key: title


import wixData from 'wix-data';

export function input1_keyPress(event) {
    let searchvalue = $w('#input1').value;
    $w('#dataset1').setFilter(wixData.filter().contains('title', searchvalue));
}

On the top right side, click on "Preview" to see if your code is working. If it is working, then you can publish.


3 Comments


Роман Грицюк
Sep 21

Часом просто хочеться відкрити кілька сайтів і вибрати тему під настрій. На Vrazhay можна почати з догляду чи стосунків, а далі перейти на Poradka, якщо більше цікавлять практичні рішення для дому або побуту. Сучасні технології та цифрові сервіси зручно читати на Infovayb, а ще більше домашніх тем, саду та різних життєвих питань можна знайти на Sutovychok, який добре завершує таку добірку.

Like

Lifehata
Sep 06

На цьому сайті зібрано багато матеріалів на теми, які можуть виникати у звичайному житті. Тут можна знайти практичні поради, зрозумілі пояснення та пізнавальні статті. Зручно, що для читання не потрібно розбиратися у складній термінології, а потрібну інформацію часто можна отримати за кілька хвилин.

Like

Infosaray
Sep 05

Корисні матеріали можна знайти на Infosaray, де зібрано статті для широкої аудиторії. Одні теми мають практичний характер, інші більше орієнтовані на пізнавальне читання. Завдяки цьому сайт залишається цікавим для різних відвідувачів.

Like
bottom of page