How to create a new search form for the "Persons" module (and other)
I would like to get two different search forms.
1. Simple search (basic criteria)
2. Extended search (More criteria)
In my case, it concerns the search in the people module, but you can take inspiration for other modules.
Step 1 - Create a new form
Go to Studio => Developer => Search Form and position on the module "Persons"
Click on "Add New Search"
And fill out the form as follows:
Name: bx_persons_ext
Content Info object: Select "Persons"
Module: Select "Persons"
Title: _bx_persons_search_extended_ext
Go in Studio => polyglot and create the key:
_bx_persons_search_extended_ext == "Persons Search Ext"
So you have this: (Field = 0 but do not worry about it at the moment)
Active new "Persons Search Ext"
Step 2 - Create a new search page
Go in Studio => Pages
Click on "Add New page" and complete as follows:
System Name: persons-search-ext
Title: persons-search-ext
Submenu: Select Persons Submenu
Layout : 2 columns 1/3 and 2/3
Cover: Checked
CREATE
Click on "Settings" for edit Page and change Title
Title:
<i class="sys-icon bx-def-font-contrasted bx-def-margin-sec-right user col-blue5"></i> People
APPLY
Step 3 - Create search and result blocks
Go to Studio => Developer => Pages => Custom and position on the page "persons-search-ext" (that you have just created)
Add two blocks of type Skeletons "service", place one on the left, the other on the right
a) Edit the left block (search) as follows:
Name: persons-search-ext
Modules: select "Persons"
Title System: Search Form Ext
Title: _bx_persons_page_block_title_search_form_ext
Uncheck:: Deletable
code:
array (
'module' => 'system',
'method' => 'get_form',
'params' =>
array (
0 =>
array (
'object' => 'bx_persons_ext',
),
),
'class' => 'TemplSearchExtendedServices',
)
b) Edit the right block (results) as follows:
Name: persons-search-ext
Modules: Select 'Persons"
Title System: Search Results Ext
Title: _bx_persons_page_block_title_search_results_ext
Uncheck: Deletable
code:
array (
'module' => 'system',
'method' => 'get_results',
'params' =>
array (
0 =>
array (
'object' => 'bx_persons_ext',
'show_empty' => true,
),
),
'class' => 'TemplSearchExtendedServices',
)
Go in studio => polyglot and create the keys:
_bx_persons_page_block_title_search_form_ext = Extended search form
_bx_persons_page_block_title_search_results_ext = Extended search results
Step 4 - Initializing the new form
Go in Studio => forms => Search Fields
Select modules "Persons"
select form "Persons Search Ext
And click on "Reset"
Your new form is created, and works independently of the first, make here the choice of fields and settings that suit you for extended search.
At this point, the new search page is accessible via the link /page/persons-search-ext and it works.
AND
You can edit the page via studio => Pages => Custom => persons-search-ext
Step 5 - Creating the New menu in Module Persons
Go in Studio => Navigation => Items
Select modules "Persons"
Select Persons Submenu
Click on "Add New Item" and complete the form as follows:
System Name: Extended Search
Title: Extended Search
Submenu: No Submenu
URL: page.php?i=persons-search-ext
Move "Extended Search" just below "Search" to be in the right place.
Note that I preferred " Search +" it takes less space...
It's over !
-
-
·
Mark Purser
- ·
Bravo! Thanks Baloo - very well explained. These are extremely valuable resources for the community, so many thanks.
-
·
Mark Purser
-
-
·
Andrey Yasko
- ·
Excellent! Alex just added a link to this in our own doc - https://github.com/unaio/una/wiki/Search-Forms
-
·
Andrey Yasko
-
-
- · Peter
- ·
Great, thy Baloo!
-
- · Amitesh Kumar
- ·
Superb
-
- · Harvliet Dalgety
- ·
Awesome. Thanks.
-
-
-
-
-
·
LeonidS
-
·
In reply to Simon
- ·
Hello Simon !
The first attached screen shows the choosing of the Persons module in the search area of the Developer app. On the second you may see the parameters popup to create a new search form. The third screen directs to the fields setup (Import FIelds step). And the last one explains what happened after the pressing of the Reset button.
-
·
LeonidS
-
OMG this is PERFECT for us! I needed to create a separate search that is available on the public part of our site, and have a bunch of the regular search options (like searching by location) be available to members only. And I did it, and it WORKS!
Thank you so much for the tutorial!