Welcome to TalkGraphics.com
Page 5 of 5 FirstFirst ... 345
Results 41 to 49 of 49
  1. #41
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Default Re: How do I add a search function

    Quote Originally Posted by Hunterdan II View Post
    The script which Acorn kindly shared is also great, if you don't mind repelling visitors who avoid google. It is a growing trend, as increasingly web users resent having their surfing habits and personal preferences harvested as data to be used in targeted advertising - I am one of those. Plus, the very use of a script that sends you to a google page not very elegant. What this basically communicates to some users is this: "You came here to look at my site, but if you want to search it I am going to send you to a google page without you being aware that it is sending you there (i.e., without your permission)" See the problem? I suggest putting a warning line under the search box (e.g. "Google search"), which then will make it okay, as you're not 'ambushing' your visitors.
    I probably can use the same approach with DuckDuckGo (https://duckduckgo.com/?q=site%3Awww...%2F+minimalist seems to work fine).
    In my defence, I did name the file Javascript - Google Site Search Form.web.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  2. #42
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Default Re: How do I add a search function

    Quote Originally Posted by jaydear View Post
    This is the OP here. I have been following the thread with interest and have to agree that it should definitely NOT be necessary to employ external software or websites to make it possible for someone to search the content of my website. It is just basically a (simple?) database query... search through the text of this website, and this website only, to find instances of the "search term" and then present a list of links for my visitors to follow. That's it, nothing more grand, though I'd expect the query to filter out common "glue" words such as "if, and, the", etc. I don't want (and can't afford) to pay others to provide this facility, and I don't want my potential customers spirited away from me or spied upon. IMHO, it is a simple facility that could easily be included in WD10, and should be. Thankyou Hunterdan II for your participation in this.
    You can always become your own search engine.
    Most Xara-generated sites are fairly static and as you are the author, you could create a list of keyword and phrases, each with a link to the site page.
    I would typically put the list into a Placeholder as an HTML table and use http://www.datatables.net/ to filter to a smaller list as a word was typed into the search box.

    A lot more maintenance but tot6al satisfaction that it is wholly internal and not reliant on Big Brother's oversight.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  3. #43
    Join Date
    May 2014
    Location
    Australia: GMT+10
    Posts
    265

    Default Re: How do I add a search function

    Quote Originally Posted by Egg Bramhill View Post
    Problem with that is a database needs php or perl access. Not all hosts provide this...
    Thanks Egg. I was curious and just had a look at the Serif Webplus x8 site. They compare their s/w in a big table with WD10 and Dreamweaver CC2014. I deduce that these three programs are in the same league, but WD10 is the one that does not have search built in (and a bunch of other stuff). I guess Serif and Dreamweaver do searches with php or perl. When I signed up for WD10 premium I was expecting things like search to just be there. Wrong again I struggle to write code, hence I got a drag'n'drop web editor. I hope that Xara can get a bit more competitive with the likes of Serif and Dreamweaver.

  4. #44
    Join Date
    Dec 2014
    Posts
    4

    Default Re: How do I add a search function

    Quote Originally Posted by Acorn View Post
    I probably can use the same approach with DuckDuckGo (https://duckduckgo.com/?q=site%3Awww...%2F+minimalist seems to work fine).
    In my defence, I did name the file Javascript - Google Site Search Form.web.
    I am so sorry, Acorn, I didn't mean to insinuate anything; you have the interest of the community at heart, this is obvious and I appreciate the great advice and input you've contributed. You are motivated by good intent, and that's what matters, in my book

    Like Jaydear I have little skill with coding, and I gave up on dreamweaver since version 4. It does appear that serif are using javascript, one of the scripts they anchor to are located in a folder called 'wpscripts' and include scripts labelled "jquery.js' and 'jsSiteSearch.js'. I am currently building a site so I had a look at the code generated for the search function. I haven't published it yet so it's not available online.

    Maybe some of the code may help make sense:

    On each page where the search box appears (in the head section):
    <script type="text/javascript" src="wpscripts/jquery.js"></script>
    <script type="text/javascript" src="wpscripts/jquery.wputils.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    $('#site_search_2_input').keypress(function(event) { if ( event.keyCode == 13 ) window.location.href = 'searchresults.html?site_search_results_1='+docume nt.getElementById('site_search_2_input').value+'&d epth=0&swr=false'; });

    $('#site_search_2_button').click(function(event) { window.location.href = 'searchresults.html?site_search_results_1='+docume nt.getElementById('site_search_2_input').value+'&d epth=0&swr=false'; });

    $("a.ActiveButton").bind({ mousedown:function(){if ( $(this).attr('disabled') === undefined ) $(this).addClass('Activated');}, mouseleave:function(){ if ( $(this).attr('disabled') === undefined ) $(this).removeClass('Activated');}, mouseup:function(){ if ( $(this).attr('disabled') === undefined ) $(this).removeClass('Activated');}});
    });
    </script>

    On the page where the search results appear, in the head:
    <script type="text/javascript" src="wpscripts/jsSiteSearch.js"></script> !!place this in the head!!

    !!SCRIPT!!

    function GetSiteSearchResults(newWindow,frameObject,frameOb jectName,fontFace,fontSize,fontColour,linkFace,lin kSize,linkColour,bgColour,resultsText)
    {
    var sTerms="";
    var iDepth = 0;
    var sURL = new String(window.location.href);
    if (sURL.indexOf("swr=true") != -1)
    return;
    if (sURL.indexOf("?") > 0)
    {
    var arrParams = sURL.split("?" );
    var arrURLParams = arrParams[1].split("&" );
    for (var i=0;i<arrURLParams.length;i++)
    {
    var sParam = arrURLParams[i].split("=" );
    var sValue = decodeURIComponent(sParam[1]);
    if( decodeURIComponent(sParam[0]) == frameObjectName)
    sTerms = sValue;
    if( decodeURIComponent(sParam[0]) == "depth")
    iDepth = parseInt(sValue);
    }
    }
    var d=frameObject.document;
    if (sTerms=="") {d.open(); d.write("<html><head></head><body style=\"background: transparent;\"></body></html>" ); d.close();return;}
    var sBack=""; for (i=0; i<iDepth; i++) sBack+='..\\\\';
    d.open();
    d.write("<!doctype html>" );
    d.write("<html lang=\"en\">" );
    d.write("<head>" );
    d.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" );
    d.write("</head>" );
    d.write("<body style=\"margin: 0px 0px 0px 0px; font-family: "+fontFace+"; font-size: "+fontSize+"; color: "+fontColour+"; background: "+bgColour+";\">" );
    d.write("<div id=\"wpSearchResults\"></div>" );
    d.write("<script type=\"text/javascript\">" );
    d.write("var wordMap = new Array(\" habitasse platea dictumst mauris rutrum enim vitae mauris proin mattis eleifend pede pretium ante amet elit quisque tellus dictum eget dapibus sodales lectus pellentesque molestie adipiscing iaculis quis arcu nulla viverra ultricies velit maecenas magna nisl ipsum rhoncus duis nisi sapien nullam tincidunt fringilla integer curabitur felis erat tempus placerat pellentesque purus diam nunc class aptent taciti sociosqu litora torquent conubia\",\" about \",\" case examples illustrate possibilities opportunities tailored online training learning \",\" access tailored online training from here habitasse platea dictumst mauris rutrum enim vitae mauris proin mattis eleifend pede pretium ante amet elit quisque tellus dictum eget dapibus sodales lectus pellentesque molestie adipiscing iaculis quis arcu nulla viverra ultricies velit maecenas magna nisl ipsum rhoncus duis nisi sapien nullam tincidunt fringilla integer curabitur felis erat tempus placerat pellentesque purus diam nunc class aptent taciti sociosqu litora torquent conubia nostra inceptos hymenaeos aenean risus porttitor vestibulum nibh faucibus justo etiam vulputate egestas neque luctus dolor hendrerit tortor metus turpis tristique lacinia suspendisse potenti feugiat lorem consectetuer cras gravida massa accumsan \",\" resources \",\" recommended links \",\" contact page \",\" terms conditions \",\" search results \",\" \" );" );
    d.write("var pageMap = new Array(\"sitename\",\"About\",\"Cases\",\"Train\",\ "Resources\",\"Links\",\"Contact\",\"terms-and-conditions\",\"search_results\",\"Services_details \" );" );
    d.write("var linkMap = new Array(\"index.html\",\"about.html\",\"page3.html\" ,\"train.html\",\"resources.html\",\"links.html\", \"contact.html\",\"page8.html\",\"searchresults.ht ml\",\"page10.html\" );" );
    d.write("var preMap = new Array(\"placerat pellentesque purus diam nunc class aptent taciti sociosqu litora torquent conubia\",\"About \",\"Case examples to illustrate possibilities and opportunities for tailored online training and learning \",\"In hac habitasse platea dictumst Mauris rutrum enim vitae mauris Proin mattis eleifend pede Sed pretium ante sit amet elit Quisque pede tellus dictum eg\",\"Resources \",\"Recommended links \",\"Contact page \",\"Terms and conditions \",\"Search results \",\"\" );" );
    d.write("function doNav(ind)" );
    d.write("{" );
    if (newWindow)
    d.write(" window.open(\""+sBack+"\"+linkMap[ind],\"_blank\" );" );
    else
    d.write(" parent.window.location.href=linkMap[ind];" );
    d.write("}" );
    d.write("function wpDoSearch(searchTerms){" );
    d.write("var terms = searchTerms.split(\" \" );" );
    d.write("if (terms==\"\") return;" );
    d.write("var results = \"\";" );
    d.write("var resultscount = 0;" );
    d.write("for (var i=0; i<wordMap.length; i++)" );
    d.write("{" );
    d.write(" var found=true;" );
    d.write(" for (var j=0; j<terms.length; j++)" );
    d.write(" if (wordMap[i].indexOf(terms[j].toLowerCase())==-1) found=false;" );
    d.write(" if (found)" );
    d.write(" {" );
    d.write(" results+=\"<a style=\\\"cursor: pointer; font-family: "+linkFace+"; font-size: "+linkSize+"; color: "+linkColour+"; \\\" onclick=\\\"doNav(\"+i+\" );\\\"><u>\"+pageMap[i]+\"</u></a><br>\"+preMap[i]+\"...<br><br>\";" );
    d.write(" resultscount++;" );
    d.write(" }" );
    d.write("}" );
    d.write("document.getElementById(\"wpSearchResults \").innerHTML=resultscount+\" "+resultsText+" \"+searchTerms+\"<br><br>\"+results;" );
    d.write("}" );
    while(sTerms.indexOf("\"") != -1 ) {
    sTerms = sTerms.replace("\"","" );
    };
    d.write("wpDoSearch(\""+sTerms+"\" );" );
    d.write("</script>" );
    d.write("</body></html>" );
    d.close();
    }

    On results page, in the body:
    </div>
    <iframe id="site_search_results_1" name="site_search_results_1" data-results="font-family: 'Verdana'; font-size: 13px; color: #000000;" data-links="font-family: 'Verdana'; font-size: 13px; color: #000000;" style="position:absolute;left:66px;top:166px;width :688px;height:490px;border:none 0px;"></iframe>
    </div>

    Not sure if this will create more confusion than help, but i thought I'd share this info so that someone in the know may be motivated to make sense of it and perhaps develop a similar function for WD.

    Thanks again.
    Last edited by Hunterdan II; 15 December 2014 at 10:12 AM. Reason: correction

  5. #45
    Join Date
    May 2014
    Location
    New York
    Posts
    62

    Default Re: How do I add a search function

    Quote Originally Posted by Acorn View Post
    The missing demonstration file: Attachment 103687
    Acorn

    Acorn.....

    DUDE!
    You are my sunshine.....my only sunshine!!!

    Thank you for the search widget....its working "fabulous" on my website
    (I could not get Google/cse function to work...their site kept freezing up)

    I just copied / pasted your widget...I took off that little bit of text at the top where it said search [[....]]

    Happy....happy....joy-joy!



    Karen

    PS: I did submit a updated sitemap.xml to BING and Google, and I have accounts both in BING and Google Webmaster Tools ....I use StatCounter as my direct monitor though, since their code doesn't slow down my website like Google Analytics' code does.

  6. #46
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Default Re: How do I add a search function

    Quote Originally Posted by KarenC View Post
    Acorn.....

    DUDE!
    You are my sunshine.....my only sunshine!!!

    Thank you for the search widget....its working "fabulous" on my website
    (I could not get Google/cse function to work...their site kept freezing up)

    I just copied / pasted your widget...I took off that little bit of text at the top where it said search [[....]]

    Happy....happy....joy-joy!



    Karen
    Karen, just what I needed to hear on a grey autumn day. Thank you,
    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  7. #47
    Join Date
    May 2002
    Location
    Canada
    Posts
    3,338

    Default Re: How do I add a search function

    Acorn, coming back to this, is there a way we can keep the results from opening up a page and display it in an iframe or same page without the other ads etc... Just the results?

  8. #48
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Info Re: How do I add a search function

    Quote Originally Posted by behzad View Post
    Acorn, coming back to this, is there a way we can keep the results from opening up a page and display it in an iframe or same page without the other ads etc... Just the results?
    behzed, here is a revamp file of my original: Javascript - Site Search Form.web.xar

    It uses DuckDuckGo instead of Google so no Ads.

    If you change target="_blank" to "_top", the results appear in the same page/tab.

    I have tried to use an IFRAME on the page to keep things on the same web page but the search sites block IFRAMEs for the results.
    I have left an IFRAME there for you to test by changeing the target to the IFRAME's name.

    Finally, I now prefer the DuckDuckGo search design page where I want the resuls to appear in the same page/tab.
    This is the bottom-most search box.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  9. #49
    Join Date
    May 2002
    Location
    Canada
    Posts
    3,338

    Default Re: How do I add a search function

    Thank you so much Acorn.

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •