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

  • 1638
  • More
Attachments
Replies (11)
    Login or Join to comment.