Announcement

Collapse
No announcement yet.

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.

    1. Select 'Library' from the ‘Design’ menu and click the 'Variables' tab.
    2. Create two variables with the names 'text' and 'image', then set them up as in the images below: -


    Click image for larger version  Name:	Annotation 2020-01-17 1443531239.jpg Views:	0 Size:	55.7 KB ID:	551933 Click image for larger version  Name:	Annotation 2020-01-17 144353123999.jpg Views:	0 Size:	54.8 KB ID:	551934

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

    3. Select the 'Layouts' tab, right click on the top entry 'Library' and select 'Find' from the menu, and in the 'Search for Text' field enter 'Standard Search Results RWD', and open the layout selected.
    4. Add the following code, and click 'OK': -


    Code:
    <Actinic:ScriptFunctionCall>Template2('<actinic:variable searchresultvariable="true" name="image" />')</Actinic:ScriptFunctionCall>
    Code:
    <Actinic:ScriptFunctionCall>Template1('<actinic:variable searchresultvariable="true" name="text" />')</Actinic:ScriptFunctionCall>
    So that it looks like the image below: -

    Click image for larger version  Name:	Annotation 2020-01-17 144353123.jpg Views:	0 Size:	151.6 KB ID:	551935

    5. Right click in the 'Library' again, select 'Find' and enter the layout name 'Javascript Header Functions' and open the layout selected.
    6. Add the following code, and click 'OK': -

    Code:
     <script type="text/javascript"> function Template2(vimage) { var first = '<img src="' + vimage +'" />'; return (first); } </script>  <script type="text/javascript"> function Template1(vtext) { var sResult = 'text:' + vtext; return (sResult);} </script>
    7. So that it looks like the image below: -

    Click image for larger version  Name:	Annotation 2020-01-17 14435312.jpg Views:	0 Size:	48.1 KB ID:	551936

    8. 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"'.

    9. Open your site folder in Windows Explorer and find the file 'actinicsearch.js'.

    10. Open the file in Notepad and find the following line:
    Code:
    sTemplate = sTemplate.replace(/(<Actinic:S_STOCK><\/Actinic:S_STOCK>)/ig, objProductDetails.m_nStockLevel);
    11. Insert the following line of code immediately below it:-

    Code:
    sTemplate = sTemplate.replace(/(<Actinic:S_PRODREF><\/Actinic:S_PRODREF>)/ig, objProductDetails.m_sProdRef);
    12. 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>
    Last edited by G.W.Green; 20-Jan-2020, 03:43 PM.
Working...
X