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 !

txvgkanbbmevxrxn5gxyya5hpbbniwfi.png

  • 1707
  • More
Attachments
Replies (17)
    • Bravo! Thanks Baloo - very well explained. These are extremely valuable resources for the community, so many thanks.

      • Excellent! Alex just added a link to this in our own doc - https://github.com/unaio/una/wiki/Search-Forms 

        • Nice job Baloo 

          • Great, thy Baloo!

              • Awesome. Thanks.

                • Very good tutorial, thanks, merci

                  • Re:
                    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
                    Baloo - Could you please provide screenshots? 😉

                    • Andrew Baloo , a video or some images to accompany the official instructions on: How to create a new search form for the "Persons" module (and other) would have been extremely helpful. I am nevertheless thankful what has been provided thus far.

                      • 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.

                        • 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!

                          • On this step, on the dropdown menu, do you leave the Module to Custom or do you switch to Persons? The upgraded interface no longer complies with these steps. We have tried Custom and Persons without seeing success in creating the new search form.

                            This is outdated --> Go in Studio => polyglot and create the key:

                            _bx_persons_search_extended_ext == "Persons Search Ext"

                            • Hello @fansfam !

                              Could you please specify what problem did oyu meet with the Polyglot's creation key? And what about search results - you didn't get it form your custom search form?

                              • when you go to polygot to generate a creation key, the form includes Module. The instructions provided do not list this step. The default is Custom module but since you using both System and persons module it is unclear which of the three modules in which to create the key. Also, Step 4 - Initializing the new form does not show the new Search form so you can not reset to initialize. We believe this is connected to the polygot creation key module.

                                • About the "Polyglot step" - well, any variant will work. For the language keys, the proper module means more friendly keys search when you may find all keys of the module at once.

                                  About non-wokring search form reset - it means that smth wasn't good during the form's creation and it needs to check in details.

                                  • Very very informative... I've tried it once on the SPACE search form, well, I wanted only the search to be done on the SAPCE value field... Putting it on the home page with the gallery view to show of some SPACES... But it seems that I would have to change the default SPACE search form, in fact, it created duplicates and I got stuck not knowing how to delete those extra fields....

                                    Speaking of which... SPACE Module is a very powerful module. It comes in handy and help replacing multi-site structure given UNA's cloud computing (database structure). More time should be invested into it...

                                    • ok. good info. Thank you.

                                      Login or Join to comment.