MENU

Direct link to searchresults Products module

  Previous article Next article  

At my no salt diet website I use the CMS Made Simple Products module for a Nutrient Database. When you want to know the nutritional values of in example an apple, you type "apple" in the searchbox, hit the submit button and you will get a list of all items containing the word "apple".

So far, so good. But what I missed is a direct link to the search resultspage in case people ask me questions about some product.

I created a work around to achieve this.

  How to use

Add to the top of your CMSMS Products Search Template:

{$keyword = $smarty.get.keyword|default:''}

Searchbox

Change in the content of the template:

<div class="row">
  <p class="row_prompt">{$mod->Lang('search_name')}:</p>
  <p class="row_input"><input type="text" name="{$actionid}cd_prodname" size="40" maxlength="255" /></p>
</div>

Into:

<div class="row">
  <p class="row_prompt">{$mod->Lang('search_name')}:</p>
  <p class="row_input"><input type="text" name="{$actionid}cd_prodname" value="{$keyword}" size="40" maxlength="255" /></p>
</div>

Submit button

Change on the bottom of the template the submit button code:

<input type="submit" name="{$actionid}cd_submit" value="{$mod->Lang('submit')}"/>

Into:

<input type="submit" id="ProdSearchSubmit" name="{$actionid}cd_submit" value="{$mod->Lang('submit')}" />
{if $keyword != ''}<script language="javascript">document.getElementById("ProdSearchSubmit").click();</script>{/if}

Advertisement



Ads help me to help you! Thanks!

Ads help me to help you! Thanks!



Show direct pagelink

At the bottom of your summary template you can add something like:

<p>This is a direct link to this page:<br />
http://www.website.com/your-page-alias?keyword={$actionparams.cd_prodname}</p>

When you open the searchpage with the direct link the search template reads the keyword string in the url. The keyword is automaticly filled in into the search field. And the javascript "clicks" at the submit button.

  Working example





  Comment Form

Click here to open the form


  1 Comment

CMS Made Simple - Tutorials, tips and tricks - CMSMS

Direct link to searchresults Products module

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1.4
  Last updated: 18-11-2017
  Comments: 1
  http://cms.ms/zLZd

Advertisement



Ads help me to help you! Thanks!

Ads help me to help you! Thanks!

Ads help me to help you! Thanks!