Direct link to searchresults Products module

  Previous article Next article  

Direct link to searchresults Products module

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1.4
  Last updated: 31-07-2016
  Comments: 1

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}

A2 Webhosting CMS Made Simple


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




A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  1 Comment

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

Direct link to searchresults Products module

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1.4
  Last updated: 31-07-2016
  Comments: 1

A2 Webhosting CMS Made Simple