Announcement

Collapse
No announcement yet.

Search by sections

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

    Search by sections

    Hi all

    We have implemented a drop down for visitors to search by sections or departments on the following client's site:

    www.stitch1knit1.com

    The search box and drop down appears on every page by virtue of having included the code for the search function into the primary template (this site uses several primary templates for the different departments).

    The following gives an example of some of the HTML that generates the drop-down:

    <SELECT NAME="SX">
    <OPTION VALUE="0">All Sections<OPTION VALUE='1'>Needlework
    <OPTION VALUE='1768'>Knitting
    <OPTION VALUE='1838'>Rug Making
    <OPTION VALUE='1896'>Accessories</SELECT>

    The above "values" were obtained from the Actinic generated search.html page which resides on the site (although we don't link to it as we do not intend for visitors to use this page).

    The Actinic generated search.html page includes all of the sections (of which there are hundreds).

    In the drop-down that we have put in the overall primary template we have cut this list down to the four top-level departments using the values that were generated in search.html.

    However. the problem with this is that whenever the site has a new section added or removed, the values assigned to the top-level sections change. And unless we change the values used in the drop-down in the overall templates, the "search by department" no longer actually searches the correct section.

    Our client really does not want to have to modify the overall templates everytime that they add or delete a section.

    Any suggestions anyone?

    Cheers

    Nick
    Hazelnet Web Solutions
    www.hazelnet.co.uk
    Actinic & Worldpay Partners
    Specialising in ecommerce and
    online promotion.

    Workwear and Promotional Clothing
    www.workwearhouse.co.uk
    Logo Your Polo!

    #2
    Whats your catalog structure?

    4 top level sections:


    Needlework
    Knitting
    Rug Making
    Accessories

    then sub sections divided between these 4 top level sections?

    If so cant you use some javascript to display the relevent dropdown?

    i.e
    ------------------------------------------------------------------------------------


    <!--@act NETQUOTEVAR:TOPLEVELSECTIONS_RAW -->
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    /***********************************************************************
    *
    * ACT_DropListBox - returns a string containing the HTML for the SELECT listbox
    *
    ************************************************************************/

    function ACT_DropListBox(ar)
    {
    var strIDs = '<SELECT SIZE="1" NAME="ACT_droplstbox" onChange="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">'
    var sel = " SELECTED"
    strIDs += '<OPTION ' + sel + ' VALUE="">Select a Section</OPTION>'
    for (var i=1;i<=ar.length;i++)
    {
    if (ar[i].sURL !=null)
    {
    strIDs += '<OPTION VALUE="' + ar[i].sURL + '">' + ar[i].sName + '</OPTION>'
    }
    }
    strIDs+='</SELECT>'
    return strIDs
    }
    //-->
    </SCRIPT>

    ------------------------------------------------------------------------------------

    Placed in the <head> of your document.

    and...

    ------------------------------------------------------------------------------------

    <form name="Act_SectionDroplist">
    <script language=Javascript1.1>document.write(ACT_DropListBox(sections))</script>
    </form>

    ------------------------------------------------------------------------------------

    Placed where you want the dropdown to apear?

    Using this method means that it will be dynamic in that everytime a change is made in actinic the menu will react to it with every update to the server.

    Reagards
    Nick Smith
    Web Developer
    extrinsica Limited

    Comment


      #3
      However. the problem with this is that whenever the site has a new section added or removed, the values assigned to the top-level sections change.
      Are you sure about this? They should always stay the same. Look for the 'NID' field in the 'Catalog Section' table in the database. This is what is used for the search, and it is fixed for each section unless you delete and then re-create the section.

      Comment

      Working...
      X