Hexagon Geospatial
MENU

WebGIS

Need a push in the right direction when configuring WebMap, Portal or SDI services? Looking for hints and tips, or just looking for Ideas and information? The WebGIS discussion board is where you start those discussions, connect and share information.
Showing results for 
Search instead for 
Do you mean 
Reply
Frequent Contributor
Posts: 134
Registered: ‎04-12-2016

Configuring the Template in Consumer Portal Layout - WMPS search

Hi team

 

I am trying to config the Confumer Portal Template to show more info in the result list - under the search box. (WMPS Serarch service)

From reading our documentations I understand there are two templates that we need to change:

1. template.json

The online documentation suggests  we need to do the following,

 

 

{
“<service_name>”
{
“<data.properties.type>”
{
“resultlist”:  ”<relative path to template>”,
“tooltip”:      ”<relative path to template>”,
“detailed”:   ”<relative path to template>”
}
}
}

So I did that and it looks as below:

 

 

{
    "WMPS01":
    {
        "address":
        {
            "resultlist": "resources/templates/address.resultlist.tmpl"
            
        }
    
	}
}

Note, WMPS01 is the name of my WMPS search service, address is the search item name I defined in Adminconsole under search configuration.

No luck for me,  an error displays saying No Default Resultlist Template. so I went ahead and started modifying the tmpl files that the json template references to.

 

2. address.resultist.tmpl

Original coding

<div class="webgis-search-item-icon webgis-search-result-marker-tooltip-type-<%=(data.properties.type || 'none').toLowerCase()%>"></div>
<span class="webgis-search-item">
    <div class="webgis-search-item-title"><%=data.match%></div>
    <div class="webgis-search-item-description"><%=data.properties.type%></div>
</span>

I replaced data.properties.type with address and now the coding looks the following:

<div class="webgis-search-item-icon webgis-search-result-marker-tooltip-type-<%=(address || 'none').toLowerCase()%>"></div>
<span class="webgis-search-item">
    <div class="webgis-search-item-title"><%=data.match%></div>
    <div class="webgis-search-item-description"><%=address%></div>
</span>

Still no go.

 

Has anyone done the same config before? Where am I going wrong?

 

Cheers

Yuan

 

 

Technical Evangelist
Posts: 1,063
Registered: ‎09-11-2015

Re: Configuring the Template in Consumer Portal Layout - WMPS search

[ Edited ]

Hi Yuan,

 

customization of the templates is quite simple but can be hard to understand from the first sight. I was able to customize search results in one of my searches and this customization is used as a part of my trainings.

 

This is how my sample WMPS search is defined:

Untitled.png

Output in Consumer Portal:

Untitled.png

 

Now let's customize this a bit. Firstly, I created a custom (HTML) template:

  • Create custom_tpl folder in …\Hexagon\Services\Instances\Consumer\resources\templates
  • For the start, copy default.tooltip.tmpl from the parent folder to the custom_tpl
  • Rename it to Alabama.tooltip.tmpl (I plan to use this template only for some of the search results)
  • Edit the tmpl file like below (note the ...-city CSS class name and custom HTML values in nested DIV elements)
<div class="webgis-search-result-marker-tooltip-type-city">
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description">City Name: <%=data.properties.description%></div>
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type">State Name: <%=data.properties.type%></div>
</div>
  • Then edit .\resources\templates\templates.json file to add our customized search result.
    • I will be using WMPS search and I will add a custom template to it but still using default templates for other results, that's why "wmpssearch" is there twice
    • Then I specify that this template will be used only for "alabama" type (type defined in AdminConsole) and for simplicity I use STATE_NAME as type.
    • Then I specify which kind of template I want to customize - in this case only the tooltips.
"apollocatalog":
    {
        "imagereference":
        {
            "detailed": "resources/templates/imagereference.detailed.tmpl"
        }
    },
"wmpssearch": // <-- default WMPS searcher
    {
        "default": "resources/templates/default",  // default templates for all web controls
        "city": "resources/templates/default"      
    },
"wmpssearch": // <-- Searcher ID / service name
    {
        "alabama": // default = all; or specify type here
        {		
            // control templates per a search result type
            // in this case we customize only tooltip control
            "tooltip": "resources/templates/custom_tpl/alabama.tooltip.tmpl"
        }
    }

And this is the result. It automatically detects type = Alabama and uses my customized template. With the city CSS class.

Untitled.png

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Frequent Contributor
Posts: 134
Registered: ‎04-12-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Thanks Jan, very helpful reply.

One more question here, what if I want to show more than two attributes in the tool tip. E.g. now I have city name, state name and I would like to show Popolation : 999999 as well.  Because of in adminconsole you are only allowed to define two attribution, where will the third attribution be entered? Does that mean you will need to create your own custom search?

 

Cheers

Yuan 

Super Contributor
Posts: 301
Registered: ‎02-10-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Hi Jan, 

 

Is there any way that I can customize layout per type and per wmps search instance. For example, I have two wmps searches address search and parcel search, I really don't want to use the same default layout for both services' results in case the types of the results don't match with what we predefine.

 

Kind regards,

 

Technical Evangelist
Posts: 1,063
Registered: ‎09-11-2015

Re: Configuring the Template in Consumer Portal Layout - WMPS search

[ Edited ]

Yuan, yes - you are limited with those fields that you define for the WMPS search in AdminConsole, other fields are not populated. You could probably workaround that using some aggregation DB field containing delimited information from 2 or more fields and then use some kind of JavaScript alchemy on the client side to extract just a portion of that string Smiley Happy There's Lo-Dash library included and might prove handful in this case, see Advanced Configuration topic here: http://bit.ly/1NIP7Ph

 

Other option is to develop your custom searcher backend. It's not hard but requires some more efforts and basic .NET programming knowledge.

============

 

Bob - I'd say it's definitely possible because it's mentioned in the docs. But I haven't have time to investigate it yet.

The outermost variable <service_name> corresponds to the name of the service (for example: “WMPSSearch”,” searchbackend”) that will use templates defined inside.

 

{
   "default": {
      "default": {
         "resultlist": " ../resources/templates/default.resultlist.tmpl",
         "tooltip": " ../resources/templates/default.tooltip.tmpl",
         "detailed": " ../resources/templates/default.detailed.tmpl"
      }
   },
   "<service_name>": {
      "<data.properties.type>": {
         "resultlist": "<relative path to template>",
         "tooltip": "<relative path to template>",
         "detailed": "<relative path to template>"
      }
   }
}

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Technical Evangelist
Posts: 1,063
Registered: ‎09-11-2015

Re: Configuring the Template in Consumer Portal Layout - WMPS search

[ Edited ]

Well it turned out that I have some good news Smiley Wink No custom searcher or attribute aggregation is needed. All the row data are already there in the WMPS response. Using Firebug and various test I was able to bring all of the columns:

Untitled.png

 

This is the template code that will reveal all of the column data:

<div class="webgis-search-result-marker-tooltip-type-city">
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description">City Name: <%=data.properties.description%></div>
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type">State Name: <%=data.properties.type%></div>
    <% _.forOwn(data.properties.original.Attributes, function(value, key) { %>
      <%=value.Key%> : <%=value.Value%>
      <br />
   <%});%>
</div>

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Super Contributor
Posts: 301
Registered: ‎02-10-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Thanks Jan, this is a great work. Smiley Very HappyIt will definitely useful for us.

Frequent Contributor
Posts: 134
Registered: ‎04-12-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

thanks Jan that will leave us with quite a lot to play with now. 

 

Yuan

Technical Evangelist
Posts: 1,063
Registered: ‎09-11-2015

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Bob, I'm still not sure about the question regarding usage of different templates for different services. I was not able to make that work. I will asked the development folks for confirmation whether this is possible or not.

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Technical Evangelist
Posts: 1,063
Registered: ‎09-11-2015

Re: Configuring the Template in Consumer Portal Layout - WMPS search

I got response from our development team that the usage of different templates for disparate services of the same types (WMPS1, WMPS2, ...) is not possible. I have suggested updating the wording in the docs.

 

Sorry for the bad news.

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.