PDA

View Full Version : Redirecting search results to iframe


aboutautism
09-02-2005, 03:02 AM
Hi
I have installed phpdig to my site:
http://www.aboutautism.org.uk/phpDig/search.php

I have created a basic page with the form from the documentation page:
http://www.aboutautism.org.uk/test.htm

I have a search results page:
http://www.aboutautism.org.uk/search.htm

Is there a way in which I can target the search queerys from my form to appear in my results page?

I would like to incorporate the form into my default template so that it is available on all pages.

Charter
09-03-2005, 01:39 PM
Does this (http://www.phpdig.net/forum/showthread.php?t=2037) thread get the results that you want?

aboutautism
09-03-2005, 11:17 PM
Thank you.
The form is now posting correctly, but it still brings up the search results in a new window, I think my problem is that I am using iframes as opposed to normal frames.
My form is thus:

<form action="http://www.aboutautism.org.uk/phpDig/search.php" target="search_results_frame" method="post">
<input type="text" name="query_string" value="">
<input type="submit" name="search" value="Go">
</form>


I have set
$result['form_head'] = "<form target='search_results_frame' action='$result_page' method='post'>
in the three locations within phpdig_functions.php as suggested.

I have created a search page, search.htm which contains an <iframe> which I have called 'search' using the 'name' function.

When I submit on my test page (test.htm) I need the search to appear within the <iframe> that exists within search.htm.

Is this possible?

Thanks

Martin

Charter
09-04-2005, 06:31 AM
When I do a search at http://www.aboutautism.org.uk/search.htm I see the search results in a frame. When I click one the the search result links, the page opens in a new window. If it is the latter you want in the same window, look for LINK_TARGET in the config file.

aboutautism
09-04-2005, 06:52 AM
Charter
Thanks for that - the links in the search page are now working much better

I am however, still stuck with my search form that I wanted to incorporate on all of my pages (see www.aboutautism.org.uk/test.htm)

Do you know if I can target my html search page ?
The html search page is www.aboutautism.org.uk/search.htm

Thanks for helping

martin

Charter
09-04-2005, 09:59 AM
In test.htm find:

<form action="http://www.aboutautism.org.uk/phpDig/search.php" target="search.htm" method="post">
<input type="text" name="query_string" value="">
<input type="submit" name="search" value="Go">
</form>

And replace with:

<script language="JavaScript">
function setCookie(name1, name2, expires, path, domain, secure) {
var querynam = 'query_string';
var queryval = document.forms[name1].elements[name2].value;
document.cookie= querynam + "=" + escape(queryval) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
</script>

<form name="query_form" action="search.htm" method="post" onsubmit="setCookie('query_form','query_string')">
<input type="text" name="query_string" value="">
<input type="submit" name="search" value="Go">
</form>

In search.php find:

if (ALLOW_RSS_FEED) {

And beforehand add:

if (strlen($query_string) == 0 && isset($_COOKIE['query_string'])) {
if (strlen($_COOKIE['query_string']) > 0) {
$query_string = $_COOKIE['query_string'];
$_COOKIE['query_string'] = '';
}
}

Keep the IFRAME in search.htm and see if these changes work.

If these changes don't work, the above may need tweaking or you can make a template like those in the templates folder.

aboutautism
09-04-2005, 12:24 PM
Sorted!!!

Thank you very much - this worked perfectly and I will now replicate test.htm to my main template / other pages.

Martin