By eriktoyra on
I have made a custom content type which I call "FAQ Page". Nodes of this type have a heading (question), body (additional info about hte question), additional body (answer to the question) as well as some vocabularys. I would like to have a "Search the FAQ" function on my "Help Center" page. This search block should only search for nodes of type "FAQ Page" and ignore all other content types. How can I do that?
Thanks in advance.
Comments
I just did this today so
I just did this today so it's freah in my head.
Investigate the source of the form that gives you 'advanced search'
Copy anything that looks useful.
I ended up with:
This interesting bits are:
where advertiser was my node-type
and
... which I learnt today.
I trimmed a little bit of formatting junk out to make this paste simpler, but this is what you need.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thanks!
Thanks dman! It works like a charm. You really should put that into the Handbook for others to read. So simple yet so useful. :)
For others interested in this. Use dman's code above with his instructions and add it to a block with input format set to PHP. Then you'll have a block which you can use in views, panels etc.
Very cool, but...
I have a problem with this. I get:
"Validation error, please try again. If this error persists, please contact the site administrator."
Weird. I understand that it's most likely the form token, but I did as you guys said. :-\
Nevermind...
I somehow deleted the 'name="form_token"' from it which broke things.
Works great now, thanks!!!!
What about multiple content types?
How would I edit this to handle multiple types like say:
page, blog, and inventory_item types
but not
job_request, site_response, or client_info types
P.S.
Figured out you could just add another hidden field per content type. However is there a way to turn this into a select list?
Not tested, but something
Not tested, but something like
May do it.
This code is a little dated now (although it still works, there may be better ways)
See also
http://drupal.org/project/search_type
http://drupal.org/project/custom_search_box
http://drupal.org/project/taxonomySearch
and others. These look like D5 mainly :-/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Didn't work I'm afraid :/ and
Didn't work I'm afraid :/ and none of those modules achieve what I'm trying to do.
Is there a way you could do this with views? I'm trying to make a custom-designed search block.
Yes!
This works great. Just what I was looking for. Thanks!
subscribe
subscribe