cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gjayne1984
Helper II
Helper II

Search page

Hi everyone

 

I'm trying to create a search page on my Power Pages site and am finding it a bit of a struggle.  Ideally I wanted to add a search box to my home page so users could search for records stored in a Dataverse table added to the site.  So far though I've only found that enabling search in the site settings displays a search icon on the top of every page in my site.

 

However, when I try clicking this icon I get the following error:

 

gjayne1984_0-1669632970812.png

Does anyone know what could be causing this?  I restarted the portal after enabling search in site settings but this hasn't helped.

 

Thanks in advance for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
mago_00
Frequent Visitor

Hi,  I think the search template is included only on certain type of portal

 

You can try creating the search template using the code below and see if it will work, this is the OOB search template that comes from customer service type portal

{% assign search_enabled = settings['search/enabled'] | boolean | default:true %}
{% assign search_page = sitemarkers['Search'] %}
{% if search_enabled and search_page %}

{% assign search_filters = settings['search/filters'] | search_filter_options %}

<form method="GET" action="{{ search_page.url | h }}" role="search" class="form-search">
    <div class="input-group">

        {% if search_filters %}
        {% assign defaultSearchFilterText = snippets["Search/Default/FilterText"] | default: resx["All"] | h %}
        {% assign searchFilterLabel = snippets["Header/Search/FilterLabel"] | default: resx["Search_Filter"] | h %}
        {% assign formId = uniqueid.new_guid %}
        <div class="btn-group btn-select input-group-btn" data-target="#filter-{{ formId }}" data-focus="#{{search_id}}">
            <li class="dropdown-submenu dropdown">
                <button id="search-filter" type="button" class="btn btn-default"
                        data-toggle="dropdown"
                        aria-haspopup="true" aria-label="{{ searchFilterLabel }}" aria-expanded="false">

                    <span class="selected">{{ defaultSearchFilterText }}</span>
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" role="listbox" aria-label="{{ searchFilterLabel }}">
                    <li role="presentation">
                        <a href="#" role="option" data-value=""
                           aria-label="{{ defaultSearchFilterText }}" aria-selected="false" tabIndex="-1">{{ defaultSearchFilterText }}</a>
                    </li>
                    {% for search_filter_option in search_filters %}
                    <li role="presentation">
                        <a href="#" role="option" data-value="{{ search_filter_option.value | h }}"
                           aria-label="{{ search_filter_option.display_name | h }}" aria-selected="false" tabIndex="-1">{{ search_filter_option.display_name | h }}</a>
                    </li>
                    {% endfor %}
                </ul>
            </li>
        </div>
        <label for="filter-{{ formId }}" class="sr-only">{{ searchFilterLabel }}</label>
        <select id="filter-{{ formId }}" name="logicalNames" class="btn-select" aria-hidden="true" data-query="logicalNames">
            <option value="" selected="selected">{{ defaultSearchFilterText }}</option>
            {% for search_filter_option in search_filters %}
            <option value="{{ search_filter_option.value | h }}">{{ search_filter_option.display_name | h }}</option>
            {% endfor %}
        </select>
        {% endif %}

        <label for="{{search_id}}" class="sr-only">
            {{ snippets["Header/Search/Label"] | default: resx["Search_DefaultText"] | h }}
        </label>
        <input type="text" class="form-control" id="{{search_id}}" name="q"
               placeholder="{{ snippets["Header/Search/Label"] | default: resx["Search_DefaultText"] | h }}"
               value="{{ params.q | url_encode }}"
               title="{{ snippets["Header/Search/Label"] | default: resx["Search_DefaultText"] | h }}">
        <div class="input-group-btn">
            <button type="submit" class="btn btn-primary"
                    title="{{ snippets["Header/Search/ToolTip"] | default: resx["Search_DefaultText"] | h }}"
                    aria-label="{{ snippets["Header/Search/ToolTip"] | default: resx["Search_DefaultText"] | h }}">
                <span class="fa fa-search" aria-hidden="true"></span>
            </button>
        </div>
    </div>
</form>
{% endif %}

 

View solution in original post

6 REPLIES 6
OliverRodrigues
Super User
Super User

Can you check via Portal Management app if you have the Search Web Template? 

 




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Pages Super User | MVP


Oliver Rodrigues


 

@OliverRodrigues thanks for the reply.  I've just checked and there's no Search web template showing up in the portal management:

 

gjayne1984_0-1669670474022.png

I'm just not sure how I go about adding it.  Apologies, but I've only just started using Portals/Power Pages so still getting to grips with it all

mago_00
Frequent Visitor

Hi,  I think the search template is included only on certain type of portal

 

You can try creating the search template using the code below and see if it will work, this is the OOB search template that comes from customer service type portal

{% assign search_enabled = settings['search/enabled'] | boolean | default:true %}
{% assign search_page = sitemarkers['Search'] %}
{% if search_enabled and search_page %}

{% assign search_filters = settings['search/filters'] | search_filter_options %}

<form method="GET" action="{{ search_page.url | h }}" role="search" class="form-search">
    <div class="input-group">

        {% if search_filters %}
        {% assign defaultSearchFilterText = snippets["Search/Default/FilterText"] | default: resx["All"] | h %}
        {% assign searchFilterLabel = snippets["Header/Search/FilterLabel"] | default: resx["Search_Filter"] | h %}
        {% assign formId = uniqueid.new_guid %}
        <div class="btn-group btn-select input-group-btn" data-target="#filter-{{ formId }}" data-focus="#{{search_id}}">
            <li class="dropdown-submenu dropdown">
                <button id="search-filter" type="button" class="btn btn-default"
                        data-toggle="dropdown"
                        aria-haspopup="true" aria-label="{{ searchFilterLabel }}" aria-expanded="false">

                    <span class="selected">{{ defaultSearchFilterText }}</span>
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" role="listbox" aria-label="{{ searchFilterLabel }}">
                    <li role="presentation">
                        <a href="#" role="option" data-value=""
                           aria-label="{{ defaultSearchFilterText }}" aria-selected="false" tabIndex="-1">{{ defaultSearchFilterText }}</a>
                    </li>
                    {% for search_filter_option in search_filters %}
                    <li role="presentation">
                        <a href="#" role="option" data-value="{{ search_filter_option.value | h }}"
                           aria-label="{{ search_filter_option.display_name | h }}" aria-selected="false" tabIndex="-1">{{ search_filter_option.display_name | h }}</a>
                    </li>
                    {% endfor %}
                </ul>
            </li>
        </div>
        <label for="filter-{{ formId }}" class="sr-only">{{ searchFilterLabel }}</label>
        <select id="filter-{{ formId }}" name="logicalNames" class="btn-select" aria-hidden="true" data-query="logicalNames">
            <option value="" selected="selected">{{ defaultSearchFilterText }}</option>
            {% for search_filter_option in search_filters %}
            <option value="{{ search_filter_option.value | h }}">{{ search_filter_option.display_name | h }}</option>
            {% endfor %}
        </select>
        {% endif %}

        <label for="{{search_id}}" class="sr-only">
            {{ snippets["Header/Search/Label"] | default: resx["Search_DefaultText"] | h }}
        </label>
        <input type="text" class="form-control" id="{{search_id}}" name="q"
               placeholder="{{ snippets["Header/Search/Label"] | default: resx["Search_DefaultText"] | h }}"
               value="{{ params.q | url_encode }}"
               title="{{ snippets["Header/Search/Label"] | default: resx["Search_DefaultText"] | h }}">
        <div class="input-group-btn">
            <button type="submit" class="btn btn-primary"
                    title="{{ snippets["Header/Search/ToolTip"] | default: resx["Search_DefaultText"] | h }}"
                    aria-label="{{ snippets["Header/Search/ToolTip"] | default: resx["Search_DefaultText"] | h }}">
                <span class="fa fa-search" aria-hidden="true"></span>
            </button>
        </div>
    </div>
</form>
{% endif %}

 

gjayne1984
Helper II
Helper II

@mago_00 perfect thanks for that.  I've added that and the search now appears

mbhatt
Regular Visitor

Hello Guys Need Help on search formula i want to use search function with this filters i am unable to add search formula showing error. (wrong column type expect text)

OliverRodrigues
Super User
Super User

hi @mbhatt I feel like your question is more Canvas Apps related, you can post your question on this forum: Building Power Apps - Power Platform Community (microsoft.com)




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Pages Super User | MVP


Oliver Rodrigues


 

Helpful resources

Announcements
Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Users online (4,726)