Customizing search

Events happening in the community are now at Drupal community events on www.drupal.org.
newz2000's picture

I've created a custom content type called "jobpost" and customized the template so that it shows the way I like. I'm now down to the problem of searching. I'd like to make it searchable so that people can type a keyword and find jobs that match it.

This article helped me do that: http://drupal.org/node/141788 So now I've got a "jobs" page that has a nice looking search box and some helpful tips.

My last hurdle is to customize the search results page. I'd like to put a heading above the search form saying something like "Ubuntu Jobs" or "Ubuntu Jobs: %searchword." Also, the search form on this page reverts to the standard ugly search box with the advanced options link (which I'd like to remove) and the search field now contains the user's original search word followed by type:jobpost

The first thing I tried was to open theme developer and see what it suggested. It said I should make a tpl file named "page-search-node-oem type:jobpost.tpl.php" which is page-search-node-{%searchphrase}.tpl.php. This would be foolish of course.

Is it possible? Do I just need to name my tpl file properly or do I need to pursue a different route?

Comments

revised question

newz2000's picture

Let me revise my question and just ask for suggestions. Here's what I'm trying to do, any tips? I've made good progress on it but I'm starting to feel like I'm fighting the system instead of working with it. (see attached)

--
Matthew Nuzum
newz2000 on freenode

--
Matthew Nuzum
newz2000 on freenode

It might be as easy as just

dldege's picture

It might be as easy as just overriding a couple theme functions related to search

http://api.drupal.org/api/function/theme_search_item/5
http://api.drupal.org/api/function/theme_search_page/5

I've mucked with search quite a bit and can give you a hand at the next DUG meeting if you can wait that long.

Dan DeGeest
Software Development Manager
iMed Studios
http://www.imedstudios.com/labs

Dan DeGeest
Software Developer
Somewhere or Another

moving up a notch

newz2000's picture

Thanks for the tips Dan, I think I need to move up one layer. I've got the search results page looking like I want except that the search form on this page looks different than I'd like. See the two highlighted regions in the attached image. I searched for the word "oem" in my custom form that limits the results to the "jobpost" content type. On the results page it puts the type:jobpost into the search field which I don't like. Also, there are advanced options, which I don't want to see.

Anyone know a way to modify the output of this part? I'm thinking that because the form submts to the standard search page for all types of searches it will be hard to customize. The implication is that I either need to be able to make a theme only when type:jobpost is searched or submit to a separate search results page just for jobs so that it can be themed uniquely.

--
Matthew Nuzum
newz2000 on freenode

--
Matthew Nuzum
newz2000 on freenode

Advanced search can be

dldege's picture

Advanced search can be controlled by a permission setting in the user access admin.

For the other thing that is related to how advanced search works see http://api.drupal.org/api/function/search_query_insert/5. I need to dig a little to see if this can be dealt with - I really need to see more of your code to see how you are customizing search.

Dan DeGeest
Lead Software Developer
iMed Studios
http://www.imedstudios.com/labs

Dan DeGeest
Software Developer
Somewhere or Another

My search code

newz2000's picture

I've not done much, only created a form with a hidden field:

<h1>Ubuntu Jobs</h1>
<form action="/search/node" method="post" id="search-form" class="search-form">
<div class="form-item">
<input type="text" class="input-text" value="" size="25" name="keys" />
<input type="submit" value="Search" name="op" title="Search" alt="Search" />
<input type="hidden" value="<?php print drupal_get_token('search_form'); ?>" name="form_token" />
<input type="hidden" value="search_form" id="edit-search-form" name="form_id" />
<input type="hidden" name="type[jobpost]" id="edit-type-your_content_type" value="your_content_type" />
</div>
</form>

I've also made a search-result.tpl.php which configures the results (not the form on the results page though):

<dt class="title">
  <a href="<?php print $url; ?>"><?php print $title; ?></a>
</dt>
<dd>
  <?php if ($snippet) : ?>
    <p class="search-snippet"><?php print $snippet; ?></p>
  <?php endif; ?>
</dd>

--
Matthew Nuzum
newz2000 on freenode

--
Matthew Nuzum
newz2000 on freenode

There are some search filter

jason ruyle's picture

There are some search filter modules out there that can restrict search to 1 content type. Install that so you don't have to add the additional content type filter. Think its called search config or might be restricted search. Also would recommend Porter Stemmer module for english language.

If you want to do more facet type search, the apache solr module is really nice. The end result would look more similar to what ubuntu job board runs.

I've used Restricted Search

Michael Hofmockel's picture

http://drupal.org/project/search_block

Regards,
Michael Hofmockel
iMed Studios

Open Source || Open Access || Open Mind

Regards,
Michael Hofmockel

Open Source || Open Access || Open Mind

Central Iowa Drupal Users Group

Group categories

Category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: