Dirty Butter Posted January 27, 2017 Share Posted January 27, 2017 I have code from Bsmither that shows the terms people used in a search. It would be great if I could use that blank space where nothing is shown, to offer suggestions - such as Didn't find anything? Please double check your spelling. Search again without "little words" such as the, with, and ... When we describe lovies we use small, large, xl if we are talking about the size. So you are not going to find it if you use huge or giant or big. ************** Any suggestions how to accomplish that? Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 27, 2017 Share Posted January 27, 2017 If it's the case where nothing was found (as opposed to a search not returning false but having an empty array of products - it could happen), we can have CubeCart do a bounce to a document. The document need not be visible, and it would contain a link back to Advanced Search. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted January 27, 2017 Author Share Posted January 27, 2017 I was hoping there was a way to stay on that page with an if/then and just add some text there, but if that's not possible a document should work. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted January 28, 2017 Author Share Posted January 28, 2017 I've slept on my last comment and changed my mind. If you could help me code to show the Search Suggestions Document IF nothing is FOUND - I think that will work just fine. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 28, 2017 Share Posted January 28, 2017 Just to cap off the previous approach: the skin template content.404.php can be externally edited to have whatever is desired. Having a separate SiteDoc allows for that SiteDoc to be in the list of other SiteDocs if desired. Shortly, I will have code to fetch the document on 404 scenarios. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted January 28, 2017 Author Share Posted January 28, 2017 I'm satisfied with my 404 page wording. I just would like the Search results Not Found to be a more more useful page. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 28, 2017 Share Posted January 28, 2017 404? My mistake. Getting confused with another thread. Step One: Create a document and enable it. Compose whatever you want to say about what to do when searches come back empty. This document will appear in the SiteDocs box, so suggest to make it relevant from a stand-alone perspective, not just only when searches come up empty. Make note of the document's "Custom SEO URL Path". It will be used in the snippet below. Step Two: Make a code snippet. Enabled: checked Unique ID: empty_search_results@cc6 Execution Order: 99 Description: 302 Bounce (to specific SiteDoc or other page) Trigger: class.cubecart.pre_display_category PHP Code: <?php if (isset($_REQUEST['search']['keywords']) && empty($products)) { // search keywords used but no products found httpredir('custom_seo_url_path.html'); } There are other ways to get basically the same end result: ?_a=template: This will find a file named inline.php in a modules folder and make it the PAGE_CONTENT of the main template. This file is not actually a template. It is a finalized chunk of HTML that will show up in the main area of the web page. ?_a=plugin: This fetches a specific hook in a plugin. The plugin need not be 100% complete. Both have their pluses and minuses. I think the 302 Bounce to a SiteDoc gives us the most versatility, especially when the SiteDoc contents can be parsed through Smarty if desired. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted January 28, 2017 Author Share Posted January 28, 2017 I've created my document and the snippet. But when I use a term that will not be found - it goes to the document correctly - but it does NOT make it clear that they arrived there because their search did not work. It would be great if it kept the Products found matching 'annniversary' were not found. Is there any way to get that 'annniversary' part into the document? IF I hide the document, I can easily change the wording to make it obvious. Should I just make TWO documents - one visible and one hidden with appropriate wording changes? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted January 29, 2017 Author Share Posted January 29, 2017 I created another document that is hidden and changed the wording to be appropriate for an unsuccessful search. The only thing that would make it more useful would be if it shows the search terms that were used in the original search. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 29, 2017 Share Posted January 29, 2017 "it does NOT make it clear that they arrived there because their search did not work" More should be added to the document making that explanation. However, I said to have content that should stand on it's own, and it sounds like that is what you have done. We can have CubeCart send the document through the Smarty Parser. 1. We will need to know what data is available at the time the document is parsed. 2. We also have globally available variables at our disposal. "IF I hide the document..." I do not know where you are going with this. Ok, let's make a few changes: Open the document for editing. Enable the Smarty parser. At the end of the document content, add {debug}. At the top of the document content, add: {if $smarty.get.search.keywords}Searched: {$smarty.get.search.keywords|escape}{/if} In the code snippet, change: From: <?php if (isset($_REQUEST['search']['keywords']) && empty($products)) { // search keywords used but no products found httpredir('custom_seo_url_path.html'); } To: <?php if (isset($_REQUEST['search']['keywords']) && empty($products)) { // search keywords used but no products found httpredir('custom_seo_url_path.html?search[keywords]='.urlencode($_REQUEST['search']['keywords'])); } Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted January 29, 2017 Author Share Posted January 29, 2017 Done. What should I look for in the debug window? The incorrect search term does show in the Not Found document - i just need to move where it is in the document, if that's possible. I made TWO Search Tip documents - one seen and one hidden that is worded appropriately to fit an unsuccessful search. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 29, 2017 Share Posted January 29, 2017 The debug window shows you what is available to add into the document. All the language phrases, some store configuration settings, but not much else. Also, Smarty gives us certain global variables. You can see what is available in a few of these variables by looking at CubeCart's debug grey section at the bottom of the page. Smarty has access to: $_GET, $_POST, $_REQUEST, $_SESSION, $_COOKIE, $_SERVER, and a few more. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted January 29, 2017 Author Share Posted January 29, 2017 I'm VERY happy with the way this turned out! As I find other unusual search terms that people use on our site I can always add more tips. THANK YOU!!! Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted June 23, 2018 Author Share Posted June 23, 2018 I've copied the snippet code over to a test 6.2.1 site and created the corresponding document. The document is enabled but not showing on the storefront. I can input the url on the storefront and it shows properly. But when I intentionally search for a junk word, it goes to the 404 page, not the document. This happens on the stock install as well. Something must be different in 6.2.1, but I don't have an idea what it is. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted June 23, 2018 Author Share Posted June 23, 2018 Never mind - I found my mistake. I did not change this part to MY custom seo path DUH! On 1/28/2017 at 6:17 PM, bsmither said: httpredir('custom_seo_url_path.html?search[keywords]='.urlencode($_REQUEST['search']['keywords'])); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.