Welcome to TalkGraphics.com
Results 1 to 3 of 3

Thread: Searching...

  1. #1
    Join Date
    Aug 2006
    Posts
    73

    Question Searching...

    Right, so I tried google's search engiene on my site, and after about a month of waiting for google to detect all of my pages and the content (even with a complete sitemap and robots.txt files) I came to understand that this would not suit my needs.

    Now, I found on one of the sites I regulary get newsletter from, a php script which allows searching that suits my needs. And then to the adaptions, I have a search engiene that searches good, now I need it to display the way I want.

    First, you might wanna know the setup;
    There are two files (or sets of code), the first is placed where you want the search to appear (see below).
    The second is the script that runs the search (class.siteseach.php).

    code from the first file:
    Code:
    <?php
    
    // Imports SiteSearch class
    require_once "class.sitesearch.php";
    
    // Creates an object called "$Search"
    $Search = new SiteSearch();
    
    // This will create search sections (you MUST create at least one).
    // All subdirectories will be searched in automatically
    $Search->addSection("Whole Site", "../");
    
    // This will allow search in documents only
    $Search->searchInDocuments(true);
    $Search->searchInImages(false);
    
    
    // This will hide directories that should NOT be opened by the search engine
    $Search->hideDir("../Hidden/");
    
    
    // This includes files .htm in the search results, and hides files .php
    $Search->addDocumentExtension("htm");
    $Search->hideDocumentExtension("php");
    
    
    // Printing search form
    $Search->form();
    
    
    echo "Here are your search results: ";
    
    // Printing search results
    $Search->results();
    
    ?>
    As you can see, it's all in one place and displays something like this:
    http://thorbear.navhost.com/images/search.jpg
    with a code something like this:
    Code:
    <form action="/xampp/Homepage/Test/se.php" method="get" name="search_form" style="text-align: center;" id="search_form">
      <div class="search_input">
        Search for
        <input type="text" name="search" id="search" value="fgnfgh" />
        <input type="hidden" name="section" id="section" value="Whole Site" />
        <input type="submit" id="submit_button" value="search" />
      </div>
      <div class="search_type">
        <input type="checkbox" name="exact_search" id="exact_search" value="yes" /> Exact Search
      </div>
    
    </form>
    Here are your search results: 
    <div id="search_results">
     Found 0 matches in 661 files<br />
     Time: 3.64 sec<br />
      <script type="text/javascript">
        var showed_page = 1;
        var total_pages = 1;
    
        function show_page(id) {
            hide_page(showed_page);
            document.getElementById('page_' + id).style.display = 'block';
            showed_page = id;
        }
    
        function hide_page(id) {
            document.getElementById('page_' + id).style.display = 'none';
        }
    
        function show_pages_links(page_number) {
            document.write('<div class="pages_links">');
    
            if (page_number > 1) {
                document.write('<a href="javascript: scroll(0, 0);" onclick="javascript: show_page(' + (page_number-1) + ');">');
            }
            document.write(' &lt;&lt; Previous ');
            if (page_number > 1) {
                document.write('</a>');
            }
    
            document.write(' | ');
    
            for (var i = 1; i <= total_pages; i++) {
                if (page_number != i) {
                    document.write('<a href="javascript: scroll(0, 0);" onclick="javascript: show_page(' + i + ');">');
                }
                document.write(i);
                if (page_number != i) {
                    document.write('</a>');
                }
                document.write(' | ');
            }
    
    
            if ((total_pages > 1) && (page_number < total_pages)) {
                document.write('<a href="javascript: scroll(0, 0);" onclick="javascript: show_page(' + (page_number+1) + ');">');
            }
            document.write(' Next &gt;&gt; ');
            if ((total_pages > 1) && (page_number < total_pages)) {
                document.write('</a>');
            }
    
            document.write('</div>');
        }
    
      </script>
    
      <div id="page_1" style="display: block;">  <script type="text/javascript">
      show_pages_links(1);
    </script>
    
    </div>
    </div>
    And finally, what I want;
    I want the search box to be viewable on all my pages, for easy access. And then when a search is made, I want it to replace the contents of that page without changing the page setup. From what I can understand I'll need to have a target for the search results. Any ideas on how to do that?

    Thanks in advance
    -Thorbear

    PS. Yell if there's any more info needed

  2. #2
    Join Date
    May 2003
    Location
    Box Elder, SD, USA
    Posts
    4,034

    Default Re: Searching...

    Manwe,

    How familiar are you with PHP and Java script? If the code looks beyond your abilites, then what ever help we may give might help or confuse you even more.

    Does your server have PHP installed and do you have permission to use PHP first off? These are questions to ask your server.
    John Rayner
    For my Photography see:
    http://www.draginet.com
    Facebook

  3. #3
    Join Date
    Aug 2006
    Posts
    73

    Default Re: Searching...

    Quote Originally Posted by raynerj1 View Post
    Manwe,

    How familiar are you with PHP and Java script? If the code looks beyond your abilites, then what ever help we may give might help or confuse you even more.

    Does your server have PHP installed and do you have permission to use PHP first off? These are questions to ask your server.
    I'm learning PHP. Javascript I understand when I see it, but I would not be able to write it out of my own head.

    My server has the newest PHP installed, and I have the premissions I want

    Thanks for the reply

 

 

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
  •