Tatttoo Posted August 23, 2013 Share Posted August 23, 2013 Hello, I have created a custom google search bar. That only searches specific sites. I have been trying to put the code in the page where i want it. I have created a page in the CMS and in the page content section i place the code in the html, but nothing ever shows. This is the code: <script> (function() { var cx = '014664903485936235509:uajjq1fvlsy'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:searchresults-only></gcse:searchresults-only> This is google's instructions on how to add this to a website's page: Copy the following code, and paste it into a <div> element in your site's <body> section, where you want the search results to render. Note: For the most cross-browser compatibility, it is recommended that your HTML pages use a supported doctype such as <!DOCTYPE html>. CSS hover effects require a supported doctype. Is this even possible for me to add to my site? Thank you Link to comment Share on other sites More sharing options...
vekia Posted August 23, 2013 Share Posted August 23, 2013 you can add this code to your website in many ways, for example: open the template.tpl file located in your theme directory (for example header.tpl) and insert this code between the {litera}{/literal} tags download free module like html block and then paste your code to the content block, select position (left column, right column, top, footer, header) and save changes. Search bar should appear automatically. With this method you can also change position of the block with search bar under the modules >positions tab in BO 1 Link to comment Share on other sites More sharing options...
Tatttoo Posted August 23, 2013 Author Share Posted August 23, 2013 Is there a way to add it to only one page? In the middle, below all the text i have? PAGE Link to comment Share on other sites More sharing options...
vekia Posted August 24, 2013 Share Posted August 24, 2013 in this case you have to edit cms.tpl page located in your theme directory. define there simple if condition; {if $smarty.get.id_cms == 6} {literal} CODE HERE {/literal} {/if} Link to comment Share on other sites More sharing options...
Tatttoo Posted August 24, 2013 Author Share Posted August 24, 2013 (edited) Thanks vekia but i have tried adding the code to the location you told me to. I get it to kinda show up but its just a empty white space. I have tried to add it various spots within the .tpl file and none of them worked? Link to Page Edited August 24, 2013 by Tatttoo (see edit history) Link to comment Share on other sites More sharing options...
Tatttoo Posted August 29, 2013 Author Share Posted August 29, 2013 Anyone can help me with this? It shows up on the page but only as a white box. Not as a search bar? Link to page= HERE Thank you Link to comment Share on other sites More sharing options...
vekia Posted August 29, 2013 Share Posted August 29, 2013 something sets "display:none" for search bar, take a look: and after disabling this param: Link to comment Share on other sites More sharing options...
Shashikant N Sharma Posted September 17, 2016 Share Posted September 17, 2016 I am unable to do this through HTML box installed on https://edupediapublications.org Please help Link to comment Share on other sites More sharing options...
Shashikant N Sharma Posted September 17, 2016 Share Posted September 17, 2016 Thanks Vekia, I have been able to use Google Custom search bar through HTML box developed by you. Link to comment Share on other sites More sharing options...
Recommended Posts