Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

submit to different page - SearchUnit - Forum

Welcome Guest Search | Active Topics | Log In | Register

2 Pages 12>
Options
RCDAwebmaster
#1 Posted : Wednesday, April 8, 2015 8:18:31 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
I'm using the trial version of SearchUnit.

I managed to place the search field and button on my page using:
<div id="sew_searchBoxControl"></div>

Once the page loads, I use javascript to tell the browser not to display the button:
document.getElementById('sew_searchButton').style.display = 'none';

Since the div is in a table and the cell next to the div has a custom button in, it looks like the search box and button go together.

The custom button evokes javascript to check the search field for text and if the field is blank, tosses a message to the searcher that “searches must include some text to search.” then sending focus to the search box, else sending the search value to the search results page.

This works, unless the searcher presses the enter key while focus in in the search field and the form submits without running the javascript event of the button which checks for search criteria and sends it to the results page. This results in the form submitting to the same page which does not show the search results. I need to send the search value to another page as all pages on the site will have the search field and there will be only one results page. How do I disable the enter key submit action on the form or add an on submit action to the form which runs the javascript?
Jim
#2 Posted : Wednesday, April 8, 2015 10:16:28 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
Hi, please see the "Two Page Setup" here

http://keyoti.com/produc...0Usage/BasicSearch.html

you might also be interested in the "Templating The Controls" on that page too.

About the form, unless I'm mistaken, it's your form (or ASP.NET's), so you can control Enter=>Submit as usual
http://stackoverflow.com...ss-to-submit-a-web-form

Best
Jim
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#3 Posted : Thursday, April 9, 2015 2:38:53 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
In the end I decided that it was easier to replace your search box and button with my own box and button because I could use an image for the button and style the textbox's background and text color to match the site. I was then able to create my own form and have it redirect to the results page. Your code was removing the form element that wrapped the <DIV> Additionally, I found it cleaner to not redirect using your script. There was no need for 2 page loads to get results. I did manage to stop the enter key from submitting forcing a button press which now checks for a search string before submitting.

Is there a way to restrict results to those that have a certain path? I ask this because I run a site that has subdirectories for offices (mysite.org/offices/humanResources/) and if I add a search page to that office, I need a way to only return results relevant to that office.

Jim
#4 Posted : Thursday, April 9, 2015 4:01:17 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
Thanks, though I'm not sure about the 2 page loads - that shouldn't be happening, but anyway if you're happy with how you've done it...

To make a form post to a new window, add 'target'

Code:

<form target="_blank"


Quote:

Is there a way to restrict results to those that have a certain path? I ask this because I run a site that has subdirectories for offices (mysite.org/offices/humanResources/) and if I add a search page to that office, I need a way to only return results relevant to that office.


Yes, there's a few ways, including Security Groups (defining user groups and assigned docs to those groups), and filters, but I think Location categories are the best fit for what you describe.

With Location categories you categorize content based on paths (or meta tags if you like), please see

http://keyoti.com/produc...ionContentChoosers.html

You might not want to use a dropdown chooser, so see the part "Setting the default Location or Content Category to search inside, with or without a control".

By the way, I'd be interested to see what you're building when it's public, if you can share it PM me or post here (not for some marketing gimmick, I really am just interested in what our customers are doing).
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#5 Posted : Thursday, April 9, 2015 4:48:46 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
I am not yet a paying customer so I can't show you what I'm building, but for the most part, I'm replacing the results page that is generated using a catalog from Windows Indexing service. The site is rcda.org and has a search function that at times does not return relevant results.

For Instance:
Under offices - Chancellors, there are documents for requesting a Papal Blessing. The current search does not return the documents in the results. Testing SearchUnit, the 2 PDFs are results #3 & #5 in the list. This is because PDF documents are not being indexed.

I've also added search capabilities to http://www.rcda.org/churches/HolySpiritChurch/ which returns results only for that sub directory. I'm also planning to add the search function to other parishes and offices down the road.

Now I'm off to learn Location categories and create searches for the parishes and offices.

Thanks for the help.
RCDAwebmaster
#6 Posted : Thursday, April 9, 2015 9:07:39 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
Maybe I don't understand locations:

I setup a new location "Holy Spirit East Greenbush" to point to /churches/holyspiritchurch

I then reimported the indexable source "http://www.rcda.org" using the windows service.

I then added the script:

<script type="text/javascript">
keyotiCategoryChoosers.setSelectedLocation("Holy Spirit East Greenbush"); //set the default location to search inside
</script>

to define which location to search within. I'm still getting results from all locations. Am I doing something wrong?

Maybe there is something I can add to the URL to get this to work? search_results.aspx?query=bible&location=Holy spirit east greenbush
Jim
#7 Posted : Friday, April 10, 2015 4:48:10 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
Ah, if you don't have the location chooser on the page then it might not pick up the change. You could manually do this to make it work

Code:

<script type="text/javascript">
keyotiCategoryChoosers.setSelectedLocation("Holy Spirit East Greenbush"); //set the default location to search inside
keyotiSearch.showPage(1, true)
</script>


BUT, it will mean 2 searches (first with default location) so better option is what you suggested

search_results.aspx?query=bible&location=Holy%20Spirit%20East%20Greenbush

Important to use %20 for space (and any other relevant URL escape sequences, eg with the JS function encodeURIComponent(text)), and also important to match the location name exactly (otherwise it searches everything).
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#8 Posted : Friday, April 10, 2015 3:21:07 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
That's fantastic. I like the fact that I can add "location=Holy%20Spirit%20East%20Greenbush" and show results from that location only. This is going to work. :-D

Now I need to configure the indexing service to index the source and populate the locations. I actually thought I had done that yesterday, but for some reason adding location to the URL gave me all search results. The hardest part of this is waiting for all 11000 items to be indexed.
Jim
#9 Posted : Friday, April 10, 2015 4:07:08 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
Couple of tips

-You can stop the index whenever and test it, of course this relies on it having indexed something under your test locations.

-Once everything is indexed, if for some reason you find that documents weren't put in the correct location, you can go to the locations tab in Index Manager, change the Root Path for a location and click the 'assign' button in the middle of the screen. It will reassign based on the root path.
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#10 Posted : Monday, April 13, 2015 4:40:14 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
Testing the windows service:

On Friday, I added a new location for my index. Instead of forcing a reimport, I decided to wait until Monday to do anything as the windows service was set to run at 1am and every 24 hours thereafter. Today, I noticed that the new location had no contents to search. How can I verify that the indexing service runs at 1am.

If you are suggesting the email feature, I set it up to send an email and I didn't get anything.

How frustrating. Also, I told the indexing service to run a few hours ago and am seeing no progress. How do I know if the service is running?

Jim
#11 Posted : Monday, April 13, 2015 6:26:30 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
Yes, it can be annoying working with hidden services especially when they're timed. Debugging via the email feature could be worse because it relies on correct server settings, login etc and could even just be treated as junk email when it comes through...

Some things I would suggest;

-Enable logging, if you do that and restart the service you will see in the log file (I believe it's called Windows_Service.txt, or similar) that it says it's running and how long until it starts indexing.

-Have you set the service to run on your index directory? Common mistake is leaving it at the default, which won't necessarily be correct. The Windows Service screen is global, not specific to your index directory - I know that is unintuitive, but we wanted the Windows Service screen in Index Manager to be integrated....

-Don't forget the trigger now button on the screen, it lets you make the service run immediately. It does this by writing a file to the index directory, and if the service is setup to work with that directory it will pickup that file (it polls for it), and start. So it is a genuine test of the service, it just removes the timed element of the setup.

Hope that helps
Jim
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#12 Posted : Monday, April 20, 2015 2:50:18 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
Getting back to opening search results in a new window, I managed to add a script to the results page that modified the target of links to open in a new window. It runs when the page finishes loading. It looks for links to documents such as PDF, DOC, DOCX, ETC...

The problem is that if I go to the second page of results, the page is not loading, only the contents of the search results DIV change, so the links do not get modified to open in a new window.

I tried looking at the files that build the search results and found the link being generated in the file RapidSearch.js
I tried changing the next link from javascript:Keyoti.nextPage(); to javascript:next(); and defining the new function in the results page but could not get the next link to change to the new function.

How do I either:

1. Add a call to my open in new window function to Keyoti.nextPage()
or
2. Get the link to call my custom function

I did find a method that might work. Adding code to the function that modifies links to open in a new window such that it repeats forever at 1 second intervals. That way if the contents of the search div change, the links still get modified. I'm not sure however if this will chew up system resources and cause the page at some point to become unresponsive.
Jim
#13 Posted : Monday, April 20, 2015 4:57:09 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
Sorry, there's a better way. Please remove your code that modified the links, you don't need it.

With reference to http://keyoti.com/produc...0Usage/BasicSearch.html

If you don't already have templates on your page, use this code for the results

Code:

    <div id="sew_searchResultControl">
        <div class="sew_ajax_loader_backer"><div class="sew_ajax_loader"></div></div>
        <div class="sew_ajax_error">
            <span class='sew_errorTitle'>Error</span>
            <p class='sew_errorBody'></p>
            <div class="sew_ajax_error_footer">
                <input type="button" value="OK" id="sew_errorOKButton" />
            </div>
        </div>
        <div id="sew_resultView">
            <div id="sew_resultHeader">
            </div>
<div id="sew_resultItemTEMPLATE" class="sew_resultItem">
                <span class="sew_resultItemLink"><a href="${UriStringWithKeywords}" target="_new">${Title}</a></span>
                <span class="sew_resultItemSummary">${Summary}</span>
                <span class="sew_previewResultWrapper"><img alt="Click to preview the document text" src="/Keyoti_SearchEngine_Web_Common/ResultPreview_Expander_Closed.png"
                    onclick="keyotiSearchResultPreviewer.toggleResultPreview(this,
                    '${UriStringAsStored}',
                    '/Keyoti_SearchEngine_Web_Common/ResultPreview_Expander_Closed.png',
                    '/Keyoti_SearchEngine_Web_Common/ResultPreview_Expander_Opened.png')"/>
                <span class="sew_previewResultContent">Loading document...</span></span>
                <div style="clear:both; height:1px;"></div>
                <span class="sew_resultItemURL">${UriString}</span>
                <span class="sew_keywordHitMap">${KeywordHitMap}</span>
                <span class="sew_location">${Location}</span>
                <span class="sew_location">${Content}</span>
                       
            </div>     
            <div id="sew_resultFooter"></div>
        </div>
    </div>



Basically it's our default template except with "target='_new'" in the link. Please note that is has the path to our scripts folder hard coded in 3 places, so change if they are not under /Keyoti_SearchEngine_Web_Common/.

Thanks, and it's good to get feedback like this as we could make opening in a new window easier.

Best
Jim
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#14 Posted : Tuesday, April 21, 2015 2:45:47 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
I tried your code and it works but it make every search result open in a new window. That is not what I want. Links that open a web document (.asp, .aspx, .html, .htm, etc.) should not open in a new window. only document like .pdf, .doc, .docx...
RCDAwebmaster
#15 Posted : Tuesday, April 21, 2015 3:19:50 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
The script that works for me is:

Code:

function init2() {
     var links = document.getElementById('sew_resultList').getElementsByTagName('a');
     var len = links.length;
     for (var i = 0; i < len; i++)
     {
        if (links[i].toString().indexOf(".pdf") > 0){
           links[i].target = "_blank";
         }

         if (links[i].toString().indexOf(".doc") > 0){
            links[i].target = "_blank";
         }
         if (links[i].toString().indexOf(".docx") > 0) {
            links[i].target = "_blank";
         }
         if (links[i].toString().indexOf(".xls") > 0) {
             links[i].target = "_blank";
         }
         if (links[i].toString().indexOf(".xlsx") > 0) {
             links[i].target = "_blank";
         }
         if (links[i].toString().indexOf(".ppt") > 0) {
             links[i].target = "_blank";
         }
         if (links[i].toString().indexOf(".pptx") > 0) {
            links[i].target = "_blank";
         }
         if (links[i].toString().indexOf(".pps") > 0) {
            links[i].target = "_blank";
         }
         if (links[i].toString().indexOf(".ppsx") > 0) {
            links[i].target = "_blank";
         }
     }
     t = setTimeout("init2()", 2000)
}
Jim
#16 Posted : Tuesday, April 21, 2015 10:30:21 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
Got it. See where we have this in the template

<span class="sew_resultItemLink"><a href="${UriStringWithKeywords}" target="_new">${Title}</a></span>

you could change it to

<span class="sew_resultItemLink"><a href="javascript: openResult('${UriStringWithKeywords}')">${Title}</a></span>

and add this function (sorry I haven't tried it, but it should be right)

Code:

function openResult(url){
var newWinDocs = [".doc", ".pdf"];//please add the rest
var found=false;
for(var i=0;i<newWinDocs.length; i++){
     if(url.indexOf(newWinDocs[i])>-1){
        found=true;         
     }
     
    
}
    if(found)
        window.open(url, 'newWin');
    else
        window.location.href = url;
}


It should open in a new window if it contains one of the items in the list, otherwise in the same window.

Best
Jim
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#17 Posted : Monday, April 27, 2015 3:23:54 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
I tried using a template as you suggested and got just the results header and footer. No result links.

I replaced:

Code:
<div   id="sew_searchResultControl" style="margin-top:50px;"></div>


with

Code:
<div id="sew_searchResultControl">
        <div class="sew_ajax_loader_backer"><div class="sew_ajax_loader"></div></div>
        <div class="sew_ajax_error">
            <span class='sew_errorTitle'>Error</span>
            <p class='sew_errorBody'></p>
            <div class="sew_ajax_error_footer">
                <input type="button" value="OK" id="sew_errorOKButton" />
            </div>
        </div>
        <div id="sew_resultView">
            <div id="sew_resultHeader">
            </div>
<div id="sew_resultList">
<div id="sew_resultItemTEMPLATE" class="sew_resultItem">
        <span class="sew_resultItemLink"><a href="javascript: openResult('${UriStringWithKeywords}')">${Title}</a></span>
                <span class="sew_resultItemSummary">${Summary}</span>
                <span class="sew_previewResultWrapper"><img alt="Click to preview the document text" src="/Keyoti_SearchEngine_Web_Common/ResultPreview_Expander_Closed.png"
                    onclick="keyotiSearchResultPreviewer.toggleResultPreview(this,
                    '${UriStringAsStored}',
                    '/Keyoti_SearchEngine_Web_Common/ResultPreview_Expander_Closed.png',
                    '/Keyoti_SearchEngine_Web_Common/ResultPreview_Expander_Opened.png')"/>
                <span class="sew_previewResultContent">Loading document...</span></span>
                <div style="clear:both; height:1px;"></div>
                <span class="sew_resultItemURL">${UriString}</span>
                <span class="sew_keywordHitMap">${KeywordHitMap}</span>
                <span class="sew_location">${Location}</span>
                <span class="sew_location">${Content}</span>
                       
            </div>     
</div>
            <div id="sew_resultFooter"></div>
        </div>
    </div>


Also, I can not get the windows service to reimport the indexable source: www.rcda.org. I have the service setup to run at 1am and rerun every 24 hours. When it runs, it should email me. the last email was on the 18th. If I manually run the import, it completes with no errors. How do I get this working?
Jim
#18 Posted : Monday, April 27, 2015 5:55:05 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
I tried that template you posted and it works for me:

Are there are JS errors appearing in F12?

How many results does it say there are in the header?

Could you give me a complete page with the problem?

Regarding the service, it might be best to start a new thread for that, but enable logging (in Configuration), restart the service and then after it should have run, check the index directory for the windows_service.txt log file (I think it's named that or very similar) - then post the contents.

Jim
-your feedback is helpful to other users, thank you!


RCDAwebmaster
#19 Posted : Tuesday, April 28, 2015 6:19:50 PM
Rank: Advanced Member

Groups: Registered

Joined: 3/31/2015
Posts: 38
I ran the page with the template and got 2737 results broken out into 10 pages. Unfortunately there are no results. See: http://www.rcda.org/search.pdf

If I remove the template, the results are shown. If I can't get this working, I will just use the single <div>and the JavaScript to modify the links.

There are no script errors.
Jim
#20 Posted : Tuesday, April 28, 2015 6:57:27 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
Location: Canada
You're welcome to post the page (as an attachment or paste the HTML), and I will try it out here.
-your feedback is helpful to other users, thank you!


2 Pages 12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.




About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.