PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > Mod Submissions

Reply
 
Thread Tools
Old 01-28-2005, 06:10 AM   #1
kristian
Green Mole
 
kristian's Avatar
 
Join Date: Jan 2005
Posts: 9
Refine search, but not based on path

In reply to: http://www.phpdig.net/forum/showthre...ghlight=refine

This is a very basic hack to allow the user to refine her/his search by selecting a radio button below the search-box.

First of all let me say that I'm very new to phpdig and I'm sure there are better ways to achieve what I'm trying to do here. Please let me know

THE modded FILE: libs/function_phpdig_form.php

Around line 197... I have put this (the head of the form):
Code:
    $result['form_head'] = "
  <script>
  function radioValue(radioButton) {
	for (var x = 0; x <= radioButton.length-1; x++)
	{
		if (radioButton[x].checked == true) return radioButton[x].value;
	}
		return radioButton.value;
	} 
  </script>
  <form action='$result_page' method='post' name='soegeform' onsubmit=\"document.soegeform.query_string.value=document.soegeform.query_string.value + ' ' + radioValue(refine_search)\";>
  <input type='hidden' name='site' value='$site'/>
  <input type='hidden' name='path' value='".htmlspecialchars($path,ENT_QUOTES)."'/>
  <input type='hidden' name='template_demo' value='$template_demo'/>
  <input type='hidden' name='result_page' value='$result_page'/>
  ";
And in the footer of the form (approx. line 214 if you have pasted the other stuff):
Code:
$result['form_foot'] = "
  <input type='radio' name='refine_search' value='anatomi' checked>Alt
  <input type='radio' name='refine_search' value='soeg_emner'>Emner
  <input type='radio' name='refine_search' value='placering=main'>Præparater
  <input type='radio' name='refine_search' value='soeg_oevrige'>Øvrige sider
  </form>";
In order for it to work you have to place a keyword on every page that is corresponds to the value of a radio button. My keywords are:
anatomi
soeg_emner
placering=main AND
soeg_oevrige
...I will paste them into my documents before I do my digging...

It works like this: When the user has selected a radio button and pressed the submit-button the JavaScript on the submit-button pastes the radio button-value into the search-box along whit what the user put (if anything). This is (naturally) done before the values are passed to the search-script (action='$result_page').

Maybe this can inspire someone? Maybe someone can achieve the same in a more clever way?

God I hate JavaScript
__________________
Kristian W.
www.beatnik.dk
www.mediabits.dk

Last edited by kristian; 01-28-2005 at 06:14 AM.
kristian 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
refine search to two or more urls fmehl How-to Forum 2 10-01-2006 12:52 PM
Limit search to this path returns no results mixle Bug Tracker 2 05-30-2005 10:24 PM
Forcing a page to always show up first in search results based on keyword derrickp How-to Forum 3 02-22-2005 12:01 PM
search_function.php: allow to exclude path(s) [based on 1.8.7] blueyed Mod Submissions 0 01-27-2005 03:13 AM
refine search but not based on path... zevince How-to Forum 3 07-08-2004 08:30 AM


All times are GMT -8. The time now is 11:45 PM.


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