Announcement

Collapse
No announcement yet.

Search Results Hack

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

    Search Results Hack

    I was going to post this in the KB thread, but thought I would wait until someone else has tested this and maybe refined it...

    This HACK allows you to use any variables and layout in your results page. Its not perfect, but until something comes out better, it'll do... and if like me you are only just entering product details its pretty easy! You must not be using your extended info page for anything else and there is a small change in one of the scripts. Note: If the product doesnt have a extended info page or the script can't find the page - it will skip and move on.

    I apologise if I make a mistake - it was complicated to do the first time and I may well have forgotton a step. Ask questions and it will prompt me <s>.

    You may test this on my site www.madmash.com and use the search on the left. CUFFLINKS and BLOCK produce results.

    If you can make this better, let us all know.

    Paul.

    ---

    If you are happy to carry on, MAKE A FULL BACKUP and then do this:

    1. SCRIPT: Open up SearchScript.pl in the actinic folded and find

    Code:
    	$ACTINIC::B2B->SetXML('S_ITEM', ($nCount + 1));
    and add underneith:

    Code:
    	
    		my $sExtendedFilename;
    		my $sExtendedHTML;
    		$sExtendedFilename = "../acatalog/ex_";
    		$sExtendedFilename .= $$rarrResults[$nCount];
    		$sExtendedFilename .= ".php";
    		if (-e $sExtendedFilename)
    			{
    			open(FH, $sExtendedFilename);
    			$sExtendedHTML = do { local $/; <FH> };
    			close(FH);
    			$ACTINIC::B2B->SetXML('S_PRODREF', $sExtendedHTML);
    			}
    This will not affect any other searches or uses of this file as it looks for a specific field which we will use later.

    2. Open up a product and select the product extended info page. You need to name the page ex_???.php whereby the ??? is the product reference (you might want to turn on the ref bit so it is next to the product name). Then add any html you want to the extended info design (this is INLINE html and not a page, so no body or html tags etc). You can use any code or variables you use anywhere else. (you can see the file format above if you want to change it). (Is there a way to pass the extendedinfo page name into the results page?)

    3.You shouldnt have extended info links on your pages (if you do, then you either should remove them or stop doing this hack). Because we are not linking to the extended info page, they don't get uploaded so we need to trigger actinic to make them and upload them. I found that doing this works, but there may be a better way and not even sure if this is needed. Somewhere on your products main page, add

    Code:
    <actinic:variable name="ExtendedInformationLinks" />
    Then open that up and add this:

    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsPopUpPageGenerated%22%20%2f%3e">
       <actinic:variable name="ExtendedInfoPageDesign"/>
    </actinic:block>
    4. Turn off index duplicates and extended info pages in the search options.

    5. Open the Search Results page. Move the "SearchResultsList" anywhere outside the form should be outside the form. Then within "SearchResultsList" it should be empty bar "SearchResult". Inside "SearchResult" should be this:

    Code:
    <Actinic:S_PRODREF/>
    This is what is replaced with the html from the extended info page (and is what supplies the script with the product reference).

    Done. Upload and test.

    <b>Known Problems:</b>
    When you link to the results page, the page skips to the input box in the search so you either have to fix this somehow or move the input box. This isnt a problem for me as I don't use it.

    You need to remove the <ACTINIC:SECTION > blob from the add to cart code. Not sure what that does, but it still works for me (maybe it wont work in logged in mode?).

    p.s. i used some bits from other people to get this working so thanks to all of those (forget who they are).

    #2
    very clever hack, colour me impressed.

    uber l33t perl skillz.

    Comment


      #3
      Paul - that is brilliant - on the basis of a quick look I think you have removed the need for duplicates on our new site, and greatly enabled product display cut in different ways - maker, type of product etc etc. Thank you

      Aquazuro - designer stainless steel accessories

      Comment


        #4
        Nice one Paul .

        Regards,
        Bruce King
        SellerDeck

        Comment


          #5
          I really, really want to implement this in V7 - is this easy/difficult?

          Aquazuro - designer stainless steel accessories

          Comment


            #6
            You could automate the creation of the helper file by adding some PHP to the Product Layout(s) that automatically writes said file.

            It should also be possible to do this without PHP via the AUG article - "Creating Additional Pop-Up Windows".
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              paul,
              as a sidenote, I went to the site, and initially tried to type into the area called "FIND", it took me a few seconds to realise that although it looked like an input field, iy was in fact a title for the "Find" area

              having said that the patch is a good one, thanks

              Comment


                #8
                Updated 08-04-08 (nice date) to simplify code in layout 'Standard Full Search Result' to use the usual layout defined for each product.

                Updated 09-05-11 to fix weird Actinic 10.0.4 quirk. Only change to layout Full Search Result.

                Updated 29-11-11 to allow for Fragments to be searchable.


                Turning the Search Results into a buyable list of products:

                This patch allows the Search Results to look like a normal list of product, complete with
                cart button, etc.

                It works by creating a small text file for each product which is incorporated into the search results.
                If you have thousands of products make sure your server can handle that number of extra files.

                It's designed for sites using Quantity on Product Page.
                It probably won't work with Single Add To Cart pages.

                This code is too big for a single post on the Forum so you'll have to do this and the following post.

                INSTALLATION

                We create an new style of popup page that will write the helper files:-.

                Go to Design / Library / Layouts.
                Right-click on any of the layout type groups in the 'Layouts' tab and select 'New Layout Type'.
                Give it a name of 'Full Search Results' and ensure you select 'Pop-up'.
                Click 'OK'.

                Right-click on this new layout type group and select 'New Layout'.
                Give it a name of 'Standard Full Search Result' and click 'OK'.

                Now double-click on this layout to edit it.
                Click the 'Edit Layout Details' button.
                Change the value in the 'Extended Info Page Filename Field' from:
                Code:
                <Actinic:Variable Name="ExtendedInfoPageName"/>
                to:
                Code:
                sr_<actinic:variable name="EncodedProductAnchor"/>.html
                Click 'OK'.
                This will automatically create a unique filename for each product containing its details.

                Now you need to put some layout code into this layout.
                In the Edit Layout Code window paste the following (this will use the layout defined for each product or fragment):
                Code:
                <actinic:block if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%21%3d%202" ><actinic:variable name="ProductLayout" /></actinic:block>
                <actinic:block if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%202" ><actinic:variable name="FragmentLayout" /></actinic:block>
                You can amend this, if required, to use other Product or Fragment Layouts - perhaps use a fixed layout that's a bit more concise.


                You now need to create a layout selector to include the new 'Full Search Results' into the store design.

                Right-click on the 'Full Search Results' group and select 'New Selector'.
                Give it a name of 'FullSearchResults'.
                Give it a prompt of 'FullSearchResults'.
                Set 'Group' to 'Other'.
                Under 'Place of Setting', select 'Site'
                Set 'Tab Name' to 'Product'.
                Change to the 'Values' tab.
                Highlight 'Standard Full Search Result' in the left list and click the '>' button to move it to the right-list.
                Change back to the 'Basic Definition' tab.
                Click 'OK'.


                Now we need to display the Full Search Results layout.

                Go to Design / Library / Layouts / Search Results, right-click 'Standard Search Result' and choose Copy.
                Rename that copy to be 'Full Search Result'.
                Double-click 'Full Search Result' and replace all code there with the following:
                Code:
                <Actinic:S_FULLRESULTS/>
                <actinic:block if="%3cactinic%3avariable%20name%3d%22SearchResultShowsName%22%20%2f%3e"> <!-- V1004 fix --> </actinic:block>
                <br clear="all" />
                <hr/>
                OK out.


                We need to put some code to actually create these helper files.
                Go to Design / Library / Layouts / Product Lists.
                For each list there (usually 3 - with matrix type icon) add the following code at the top:
                Code:
                <actinic:variable name="FullSearchResults" />
                Repeat for all layouts there.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  And the second bit:

                  Now a tweak is needed to the Search Results Page Bulk Area to allow for product forms in the results.
                  Go to Design / Library / Layouts / Web Page Inner Layout / Search Results Page Bulk Area.
                  Replace all code there with:
                  Code:
                  <table border="0" cellpadding="10" width="<actinic:variable name="ACTSTDWIDTH" />" align="center">
                     <tr>
                        <td>
                           <b><Actinic:Variable Name="SearchResultSummary"/></b><br />
                           <Actinic:Variable Name="SearchResultContinue"/>
                        </td>
                     </tr>
                     <tr>
                        <td>
                           <actinic:variable name="SearchResultsList" />
                        </td>
                     </tr>
                     <tr>
                        <td>
                           <b><Actinic:Variable Name="SearchResultSummary"/></b><br />
                           <Actinic:Variable Name="SearchResultContinue"/>
                        </td>
                      </tr>
                  </table>
                  
                  <hr size="1" />
                  
                  <form method="get" action="<actinic:variable name="OnlineScriptURL" value="Search Script URL" />">
                  <input type="hidden" name="RANDOM" value="<actinic:variable name='Random'/>" />
                  
                  <actinic:block if="%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e">
                     <!-- Hidden field when in trial mode -->
                     <input type="hidden" name="SHOP" value="<Actinic:Variable Name="HiddenFields"/>" />
                  </actinic:block>
                  
                  <input type="hidden" name="PAGE" value="SEARCH" />
                  
                  <table border="0" cellspacing="0" cellpadding="0" width="<actinic:variable name="ACTSTDWIDTH" />" >
                     <tr>
                        <td colspan="2" valign="top">
                           <Actinic:Variable Name="SearchPrompt"/> <Actinic:Variable Name="RetailOnlyWarning"/>
                           <br /><br />
                        </td>
                     </tr>
                     <tr>
                        <td valign="top" align="center">
                           <table border="0" cellspacing="0" cellpadding="3">
                              <tr>
                                 <td valign="top">
                                    <b><Actinic:Variable Name="SearchString"/></b><br />
                                    <input type="text" name="SS" size="40" />
                                    <br />
                                    <Actinic:Variable Name="SearchCombine"/>
                                    <input type="radio" name="TB" checked="checked" value="A" />
                                    <Actinic:Variable Name="SearchAndPrompt"/>
                                    <input type="radio" name="TB" value="O" />
                                    <Actinic:Variable Name="SearchOrPrompt"/>&nbsp;<Actinic:Variable Name="SearchCombineText2"/>
                                    <script language="javascript" type="text/javascript">
                                    <!--
                                       for (nIndex = 0; nIndex < document.forms.length; nIndex++)
                                        {
                                         if (document.forms[nIndex] && document.forms[nIndex].SS)
                                           {
                                           document.forms[nIndex].SS.focus();
                                           }
                                        }
                                    // -->
                                    </script>
                                 </td>
                                <td valign="top">
                                    <actinic:block if="%3cactinic%3avariable%20name%3d%22PriceSearchIsAllowed%22%20%2f%3e">    
                                      <b><Actinic:Variable Name="SearchPriceRangeLabel"/></b>
                                      <br />
                                      <actinic:variable name="SearchPriceBandList" />
                                   </actinic:block>
                                </td>
                              </tr>
                              <actinic:variable name="SearchablePropertyList" />
                              <actinic:block if="%3cactinic%3avariable%20name%3d%22IsSearchablePropertiesCombinedWithAnd%22%20%2f%3e" />
                                 <input type="hidden" name="GB" value="A" />
                              </actinic:block>
                              <actinic:block if="%3cactinic%3avariable%20name%3d%22IsSearchablePropertiesCombinedWithOr%22%20%2f%3e" />
                                 <input type="hidden" name="GB" value="O" />
                              </actinic:block>
                              <actinic:block if="%3cactinic%3avariable%20name%3d%22SearchBySectionsUsed%22%20%2f%3e" />
                                 <tr>
                                    <td colspan="2" valign="bottom"> <b><Actinic:Variable Name="SearchControlLabel"/></b><br />
                                       <select name="SX">
                  								<actinic:block if="%3cactinic%3avariable%20name%3d%22SetupSearchAllSections%22%20%2f%3e%20%3d%3d%20False">
                  									<option value="0"> </option>
                  								</actinic:block>
                                          <actinic:variable name="SearchSectionList" />
                                       </select>
                                   </td>
                                </tr>
                             </actinic:block>
                             <tr>
                                <td colspan="2"valign="bottom">
                                   <input type="submit" name="ACTION" value="<Actinic:Variable Name="SearchLabel"/>" />
                                </td>
                             </tr>
                          </table>
                        </td>
                     </tr>
                  </table>
                           <!-- alert("<Actinic:Variable Name="UnregCustomersNotAllowedMessage"/>");
                           return false; -->
                  
                  </form>
                  OK out.


                  The final patch is to edit SearchScript.pl (in your Site folder - back it up first).
                  Look for the line:
                  Code:
                  $ACTINIC::B2B->SetXML('S_ITEM', ($nCount + 1));
                  Immediately under it add the following:
                  Code:
                  		#
                  		# Full Search Results Hack
                  		#
                  		my $sResultsProdref = $$rarrResults[$nCount];					# the product ref
                  		$sResultsProdref =~ s/([^A-Za-z0-9])/sprintf("_%02x", ord($1))/seg;		# transform non alphanumerics like EncodedProductAnchor
                  		my $sResultsFilename = 'sr_a' . $sResultsProdref . '.html';			# form filename
                  		my $sResultsFullFilename = '<actinic:variable name="PathFromCGIToWeb" />' . $sResultsFilename;
                  		if (-e $sResultsFullFilename)							# look for file
                  			{
                  			open(FH, $sResultsFullFilename);
                  			my $sResultsHTML = do { local $/; <FH> };				# load entire file
                  			close(FH);
                  			$ACTINIC::B2B->SetXML('S_FULLRESULTS', $sResultsHTML);			# and store for display
                  			}
                  		else
                  			{
                  			$ACTINIC::B2B->SetXML('S_FULLRESULTS', 'Not found: ' . $sResultsFilename);	# error if not found
                  			}
                  Save and exit.


                  That's things installed. Your site should operate as before.

                  Now the final stage is to replace the usual search results with our new all-singing ones.
                  Go to Settings / Site Options / Layout / Other / Search Result Layout and select 'Full Search Results'.
                  You can switch back to the olde Search Results by selecting 'Standard Search Results'

                  That's it. Do a Site Update and see how the search results performs.
                  Last edited by NormanRouxel; 21-Nov-2007, 05:52 PM. Reason: Amended SearchScript.pl 21-11-07 to deal with non-alphanumerics in product ref.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    Update: You cannot use the Product Reference (or ProductID) to generate filenames. The Perl line in post#1 above
                    Code:
                    		$sExtendedFilename .= $$rarrResults[$nCount];
                    Will create an invalid filename if the Product Reference contains a forward or back slash, etc. E.g. / \. As this is quite common - ACME/1234 - it will be necessary to ensure that you either never use such characters or automatically replace them with something safe.

                    I've altered my patch above to use EncodedProductAnchor which is always filename safe. And added some tweaks to the SearchScript Perl to translate the Actinic product references into the corresponding anchor strings.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      I have followed your instructions above, the pages have been created (I can view them in the html folder of my site), but the search results page does not display them. I get the correct number of results, but just a series of horizontal lines with nothing between them (the area where the results should be).
                      What did I miss? Is there a setting that needs to be changed for linking to external files??

                      Here is the url: http://trials.actinic.com/trials/trial45254/index.html
                      Last edited by outboxin; 01-Nov-2007, 09:55 PM. Reason: Edited to add url

                      Comment


                        #12
                        norm: this is magical as well. you perl people make me proud to be an Actinician.

                        I did the exact same thing, but with ajax.

                        i'll post some code if i manage to get it togther.

                        Comment


                          #13
                          Lauren

                          I see from your URL that you are testing on an Actinic trial server. Perhaps that is preventing the patched SearchScript.pl from being uploaded.

                          Check with Actinic and report back.
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #14
                            Norman,
                            Thanks for your response.
                            I moved the site to my server (you were correct about the search script being uploaded).
                            Search results still not working.
                            Url is http://www.outboxin.com/skoshop.html

                            Thanks again.
                            Lauren

                            Comment


                              #15
                              When I look in your generated search results I see (for each line returned)

                              <Actinic:S_FULLSEARCHRESULTS/>

                              However I don't see <Actinic:S_FULLSEARCHRESULTS/> anywhere in my patch. I do see <Actinic:S_FULLRESULTS/>. Creative editing perhaps?
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment

                              Working...
                              X