Search Box

rhys
rhys Community Member Posts: 49
Some months ago I set about finding a solution to a problem I had that required a search box being included in a project. Having spent a lot of time searching this forum and many others the opinion seemed to be that this was not quite as easy as I needed. Using Lectora to publish on a network drive to act as helpfile for users, various reasons made all the solutions I could find not suitable. I noticed on this forum that in the past others had started topics about a search box, so I guess at least some people would find this ability useful.



By using JavaScript I have been able to come up with a solution. Attached is a file containing the code. For anyone who wishes to use it very little amendment is required. You dont need to understand JavaScript to use this, you just need a text editor such as notepad on Windows systems, and with a very small number of amendments to the text you can have this working in your own projects.



1: Down load and open the attached file.



2: For those not familiar with JavaScript dont be scared by the code, everything you do will just be changes to text.



3: We need to specify the number of items that are searchable. Look for the part of the code that 'reads title[0]=3' The '3' tells the script how many searchable items there are. This must be changed to match the number of searchable items in your project. For example your project has 10 articles in it you want users to be able to find by searching keywords, simply change the '3' to 10. If you add to or remove content in the future change this number accordingly.



4: Set the Keywords and links. Look for the code that reads:

title[1]="a list of keywords"

desc[1]="a description of keyword search 1"

links[1]="the link to first item"

matched[1]=0



title[1]= is the first thing to change. the section "a list of keywords" replace the text to contain the keywords relating to that topic. E.G. If you had an article about winter you might want the keywords to read "snow ice blizzard"



desc[1]= this is a descrition of the article or page that the user will see, for example "Winter - the cold season"



links[1] here you place the link to the article. So for instance a page called winter in your project would have a link of winter.html you can find this easily by going to the folder your project is stored in and checking the name of the html documents.



Your first item is now searchable. You can copy and paste this section as many times as needed for each of the searchable items in your project. Just make sure on each line of the section of code you change the [1] to [2] for the second item [3] for the thrid item and so on.



5: Once you have set all the searchable items save your file as .html and insert it to Lectora using the insert custom HTML option.



I hope this all makes sense and is of some use to someone. Let me know if you have any problems using it and I will try to help.

Comments

  • ssneg
    ssneg Community Member Posts: 1,466 ☆ Roadie ☆
    Not really a search box, more like an index box, but impressive job anyway! Thank you for sharing this!
  • rhys
    rhys Community Member Posts: 49
    Yeah prehaps seach box is a little misleading. I didnt mean to be :(



    I use it in a small intranet of very short how to guides that are typically only a couple of paragraphs long, the search terms will always for my use be quite limited. What I plan to do next though is add to is so that on submit it posts the search data to my google drive that way I can develop the index so that if users are searching keywords that I have omitted I can easily add them, or f they are looking for a type of guide that does not exist I can get it added. Its not a perfect site search engine, but for sites like mine that have to be published to a network drive rather than the web its a useable solution.



    Thanks for giving some feedback on it. :)
  • ssneg
    ssneg Community Member Posts: 1,466 ☆ Roadie ☆
    So I built a fully-functional search for Lectora. I'd appreciate it if you could share your opinion.

    http://lectora.com/forum/showthread.php?t=14430&p=49988#post49988
Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!