Announcement

Collapse

Sellerdeck Community upgrade

18 May: completed upgrade of the Sellerdeck Community software. Please report any issues in this post.
See more
See less

How do I add my own variables to the filter results?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I add my own variables to the filter results?

    The SellerDeck main help describes how to include your own variables in the search results. The same variables can also be included in filter results. However since these pages are controlled by Javascript, a small snippet of Javascript must be used instead of the code described in the help. This article describes the general method through a worked example.

    NB 'Searchable' and 'Upload' must be ticked in the variable's definition in the Library.

    We will use the 'brand' variable as an example, but the same method will work with any variable you have added yourself.
    1. Select 'Library' from the ‘Design’ menu and click the 'Layouts' tab.
    2. Scroll down and expand the 'Search Results' layout type.
    3. Double-click the ‘Standard Search Result’ layout.
    4. In the ‘Layout Code’ window, position the cursor at the top of the layout and paste the following:
      Code:
      <script type="text/javascript">
      		function Template1(vbrand)
      		{
      		var sResult = 'Brand: ' + vbrand;
      		return (sResult);
      		}
      </script>
      (Instead of 'brand' you would use the name of your own variable).

    5. Now click where you want your variable to appear, and insert the following:
      Code:
      <Actinic:ScriptFunctionCall>Template1('<actinic:variable searchresultvariable="true" name="brand" />')</Actinic:ScriptFunctionCall>
      (Again, substitute your own variable name for 'brand')

    6. Click ‘OK’, then ‘Close’ and upload the site.
      The method can also be used to insert multiple variables. You can also include the Product Reference using the variable SearchResultProductReference, but this requires the following Javascript change and the variable must not have the attribute 'searchresultvariable="true"'.
    7. Open your site folder in Windows Explorer and find the file 'actinicsearch.js'.
    8. Open the file in Notepad and find the following line:
      Code:
      sTemplate = sTemplate.replace(/(<Actinic:S_STOCK><\/Actinic:S_STOCK>)/ig, objProductDetails.m_nStockLevel);
    9. Insert the following line of code immediately below it:
      Code:
      sTemplate = sTemplate.replace(/(<Actinic:S_PRODREF><\/Actinic:S_PRODREF>)/ig, objProductDetails.m_sProdRef);
    10. Save and close the file and upload the site.


    For example, to include both the Brand and the Product Reference, with an appropriate label for each, you would add the following script functions:

    Code:
    <script type="text/javascript">
    		function Template1(vSearchResultProductReference)
    		{
    		var sResult = 'Ref: ' + vSearchResultProductReference;
    		return (sResult);
    		}
    		function Template2(vbrand)
    		{
    		var sResult = 'Brand: ' + vbrand;
    		return (sResult);
    		}
    </script>
    and the following calls (which can be put in separate places in the layout if required):
    Code:
    <Actinic:ScriptFunctionCall>Template1('<actinic:variable name="SearchResultProductReference" />')</Actinic:ScriptFunctionCall>
    Code:
    <Actinic:ScriptFunctionCall>Template2('<actinic:variable searchresultvariable="true" name="brand" />')</Actinic:ScriptFunctionCall>
Working...
X