PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 03-23-2004, 09:41 AM   #1
kh44na
Green Mole
 
Join Date: Mar 2004
Posts: 5
Search Results

Hello,

Instead of having my search results displayed in the traditional "php dig template page" - I wanted to have the search results placed into a page on my website that matches the "look and feel" or "design" of my website more accurately.

Would anyone be able to assist me in how I can go about doing so?

Thanks in advance.

Last edited by kh44na; 03-23-2004 at 09:50 AM.
kh44na is offline   Reply With Quote
Old 03-24-2004, 09:03 AM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. There is a tutorial here on how to include files in the templates, but if you want to have your own page from scratch, just do the following.

In search.php use 'array' rather than $template, assigning the output from phpdigSearch to a variable, like so:
PHP Code:
$the_output phpdigSearch($id_connect$query_string$option$refine,
              
$refine_url$lim_start$limite$browse,
              
$site$path$relative_script_path'array'); 
Afterwards add the following line:
PHP Code:
print_r($the_output); 
Then using a known keyword, do a search via URL (http://www.domain.com/dir/search.php?query_string=keyword) to see all the key value pairs that could be used.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 03-25-2004, 11:40 AM   #3
Josiah
Green Mole
 
Join Date: Mar 2004
Posts: 6
When I'm replacing the $template variable with 'array' -- do I just leave it as 'array', or do modify the 'array'?

I tried using your code as-is, and something is going wacko.
Josiah is offline   Reply With Quote
Old 03-25-2004, 02:32 PM   #4
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. Just leave it as posted, and then after doing a search, you'll see key value pairs that you can use in a custom page. For example, searching for the word test would produce a similar key value pair as the following, assuming the word test is a keyword in your table:

[result_message] => Results 1-9, 9 total, on "test" (0.32 seconds)

To display the 'Results 1-9, 9 total, on "test" (0.32 seconds)' result message in a custom page, just use the following:
PHP Code:
echo $the_output['result_message']; 
That is, if you replace:
PHP Code:
print_r($the_output); 
with the following:
PHP Code:
echo $the_output['result_message']; 
then the only thing you will see onscreen is the following:

Results 1-9, 9 total, on "test" (0.32 seconds)

If you were to replace:
PHP Code:
print_r($the_output); 
with the following:
PHP Code:
include "custom_search_page.php"
then you could use the $the_output['key'] variables in the custom_search_page.php file.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 03-25-2004, 07:13 PM   #5
Josiah
Green Mole
 
Join Date: Mar 2004
Posts: 6
I'm doing something wrong, but here's my stab at it -- tell me what's wrong....

PHP Code:
$output phpdigSearch($id_connect$query_string$option$refine,
               
$refine_url$lim_start$limite$browse,
               
$site$path$relative_script_path'array');
               
echo 
$output['powered_by_link'],
    
$output['title_message'],
    
$output['phpdig_version'],
    
$output['nav_bar'],
    
$output['pages_bar'],
    
$output['next_link'],
    
$output['form_head'],
    
$output['form_foot'],
    
$output['form_title'],
    
$output['form_select'],
    
$output['form_button'],
    
$output['form_radio'],
    
$output['results'],
    
$output['weight'],
    
$output['img_tag'],
    
$output['page_link'],
    
$output['limit_links'],
    
$output['filesize'],
    
$output['update_date'],
    
$output['complete_path'],
    
$output['link_title'],
    
$output['text']; 
Josiah is offline   Reply With Quote
Old 03-25-2004, 07:20 PM   #6
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. Try checking the HTML source and then order the $output['key'] variables so that they make correct HTML output.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 03-25-2004, 09:16 PM   #7
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. Here's more info...
PHP Code:
$output phpdigSearch($id_connect$query_string$option$refine,
                       
$refine_url$lim_start$limite$browse,
                       
$site$path$relative_script_path'array');

if (
is_file("custom_search_page.php")) {
    include 
"custom_search_page.php";
} else { exit(); } 
Save the following in the same directory as the search.php file.
PHP Code:
<?php
// custom_search_page.php

if (eregi("custom_search_page.php",$_SERVER['SCRIPT_FILENAME']) || 
    
eregi("custom_search_page.php",$_SERVER['REQUEST_URI'])) {
    exit();
}

echo 
"<html><body>";

echo 
$output['result_message'],
     
$output['powered_by_link'],
     
$output['title_message'],
     
$output['phpdig_version'],
     
$output['nav_bar'],
     
$output['pages_bar'],
     
$output['next_link'],
     
$output['form_head'],
     
$output['form_title'],
     
$output['form_field'],
     
$output['form_select'],
     
$output['form_button'],
     
$output['form_radio'],
     
$output['form_foot'];

if (!empty(
$output['results'])) {
    
$num_out count($output['results']);
} else { 
$num_out 0; }
$num_start $lim_start 1;
$num_end $lim_start $num_out;

for (
$i=$num_start$i<=$num_end$i++) {
     echo 
$i.". ";
     
$output2 $output['results'][$i];
     echo 
$output2['weight'],
          
$output2['img_tag'],
          
$output2['page_link'],
          
$output2['limit_links'],
          
$output2['filesize'],
          
$output2['update_date'],
          
$output2['complete_path'],
          
$output2['link_title'],
          
$output2['text'];
     echo 
"<br><br>";
}

echo 
"</body></html>";

?>
Remember to remove any "word" wrapping in the above code.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 03-26-2004, 05:26 AM   #8
Josiah
Green Mole
 
Join Date: Mar 2004
Posts: 6
Quote:
Fatal error: Call to undefined function: ____eregi() in [pathto]public_html/search/custom_search_page.php on line 4
Josiah is offline   Reply With Quote
Old 03-26-2004, 03:06 PM   #9
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. The eregi function is a defined function. Check the custom_search_page.php for extra or missing characters, and for incorrect code wrapping. Also, when doing copy paste, do the paste into a text only editor, and then save the file.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 03-27-2004, 09:42 AM   #10
Josiah
Green Mole
 
Join Date: Mar 2004
Posts: 6
Worked great! Thanks, Charter!
Josiah is offline   Reply With Quote
Old 03-29-2004, 03:55 AM   #11
gooseman
Green Mole
 
Join Date: Mar 2004
Posts: 11
Highlighted text extract or summary

I'm using the same method to customise the output.

But I find that using $output['text'] on my site just outputs the metatag description.

If I use the template output included, the output is an extract of the page eg. blah blah blah keyword blah... keyword blah blah... etc...

How do I output the ['text'] so that it appears as in the template?

Many thanks!
gooseman is offline   Reply With Quote
Old 03-29-2004, 05:24 AM   #12
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. Are you using the code in this post?
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 03-29-2004, 05:59 AM   #13
gooseman
Green Mole
 
Join Date: Mar 2004
Posts: 11
Yeah!

I realised I set the config to not do context searches (CONTENT_TEXT = 0), as I couldn't index on my server. I'm now doing it locally. I've set the flag back to 1 and it's working now! Doh! Thanks
gooseman is offline   Reply With Quote
Old 05-05-2004, 09:21 AM   #14
motopsycho
Green Mole
 
Join Date: Mar 2004
Posts: 11
Hope I am not intruding...

Hello,
This thread was exactly what I was looking for. It worked great. Could I bother you for some idea of how to add the keyword highlighting to your custom code above?


Thanks.
motopsycho is offline   Reply With Quote
Old 09-08-2004, 01:03 AM   #15
OceanSurf
Green Mole
 
Join Date: Sep 2004
Posts: 7
I used Charters code posted 03-26-2004 06:16 AM
this is how I made my highlighting. not perfectet it thou.

Add this function to your custom_search_page.php
PHP Code:
function color_result($text) {
    
// explode the keywords
    
$keywords explode(" "$_REQUEST['query_string']);
    
// now color the words 
    
foreach ($keywords as $replace)
        {
         
$text str_replace($replace"<font color=\"#FF0000\"><b>".$replace."</b></font>"$text);
        }
    return 
$text;    

and at the bottom when printing the result use it like this:
PHP Code:
echo color_result($output2['text']); 
i tried it a couple of times and it worked just fine (for now ).
OceanSurf is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search all indexed pages in search.php nightrat How-to Forum 1 09-14-2004 03:52 AM
Config Problem with Search on different pages. -ding-dong- Troubleshooting 2 08-24-2004 10:18 AM
converted from html pages to php pages now no pages will index!!! help!! bigals Troubleshooting 24 04-01-2004 09:34 AM
Highlighting of words and search pages rafarspd Mod Requests 0 12-02-2003 07:13 AM


All times are GMT -8. The time now is 12:32 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.