[drupal-devel] [feature] Search module should have a simple search block

tangent drupal-devel at drupal.org
Tue Feb 22 21:51:15 UTC 2005


 Project:      Drupal
 Version:      cvs
 Component:    search.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  erikhopp
 Reported by:  [viz]
 Updated by:   tangent
-Status:       active
+Status:       patch
 Attachment:   http://drupal.org/files/issues/search_block_1.patch (1.61 KB)

The attached patch adds a hook_block and uses search_form to add the
form to the block. I've extended the search_form function so that
modules can alter the text prompt as having the prompt visible in a
block looks bad.
I created this patch prior to searching for this issue to apologies to
those who have put in work on this.


tangent



Previous comments:
------------------------------------------------------------------------

November 23, 2002 - 03:34 : [viz]

Hey just one quick question/feature request.  There may be an obvious
way to do this, but I am stumped.
Documentation only lists a way to put all "left" blocks on the left,
and "right" blocks on the right (I already modded xsilver to work for
my site's style) - but what if I have a split header for my page
(graphics on left, dynamic content on the right) and I want to offer
the search block on the right half if a user is logged in, and a login
block there if they aren't?  I sniped the code out for a search and
that appears there now ( linux.trustdevelopment.com  ) but I don't want
it to appear for users that aren't logged in, since I want searching to
be one of the "premium services" that a person would want to register
an account for...
Thanks...
Josh


------------------------------------------------------------------------

March 12, 2003 - 01:06 : al

You need to create a search.module that puts a search box in a block,
using the already existing search permission to determine whether users
can access it (i.e. it gets displayed) or not.
I'm moving this to a contribs feature request. Maybe someone will want
to implement it for you. It would be really trivial to do...


------------------------------------------------------------------------

May 29, 2003 - 20:46 : al

After some thought, I've decided that having the search module able to
put a simple search text box in a block with a "search" button would be
a useful thing to do. I'm therefore reassigning the project, etc. for
this and changing the summary to reflect this.
This would be really very easy to implement. Anyone?


------------------------------------------------------------------------

May 29, 2003 - 23:45 : erikhopp

hey.  
ok, so i don't really know php and i haven't really played with the
drupal core too much, so maybe it's not right, but i think i have
created a block for the search module.  
it works on my site (i think).  the only problem is that i just cannot
figure out how to change the size of the input box. it is set at 50 for
the search page, but i can't seem to figure out where that value is set
(and i feel like i have looked everywhere).  
so if someone can change that, i think this feature request is done.  
oh - and i still have not spent the time to figure out how to add stuff
via cvs so the search module is here:
http://mediamutiny.org/search.module
and i updated the $id.  i'm not sure if i am supposed to do that or
not.  
i hope this helps...
erik.


------------------------------------------------------------------------

May 30, 2003 - 00:46 : al

Your module looks like it returns the search results inside the block,
which isn't quite what's wanted. This is actually a bit of a mess - the
search_form function should be able to do what we want, but you can't
actually use it due to various issues (like the width).
I note that the xtemplate theme uses its own search form. I'm sending a
patch to the mailing list that does the same thing.
BTW, the $Id: $ field in files is generated automatically by the CVS
server. Don't alter it yourself - it'll make us all terribly
confused...


------------------------------------------------------------------------

June 19, 2003 - 10:15 : al

A patch to implement this has been sitting in my sandbox for ages. Dries
- is there something wrong with the patch? Or do you just not think this
to be a valid feature request? Should it be done with a completely
seperate module? Or be theme-specific?


------------------------------------------------------------------------

September 8, 2003 - 17:55 : erikhopp

so what is the status of this search block patch?  i'd like to see it
added if it works ok.
erik.


------------------------------------------------------------------------

October 28, 2003 - 00:17 : erikhopp

one more attempt to get this committed...
the patch is still in al's sandbox...
i have it enabled on one of my sites and it works great...
erik.


------------------------------------------------------------------------

April 20, 2004 - 18:30 : kepol

I need a search block so I'm writing one right now, but maybe you guys
have one floating around already??? If so, where is it? :)
Thanks,
Kristen


------------------------------------------------------------------------

April 20, 2004 - 18:51 : gordon

Actually when ever I need a search block I actually just create a custom
block and I have never had a problem, see below.
<form action="index.php?q=search" method="post">
  <br />
  <input type="text" class="form-text" size="15" name="keys" />
  <input type="submit" class="form-submit" value="Search" />
</form>


------------------------------------------------------------------------

June 18, 2004 - 17:02 : erikhopp

Attachment: http://drupal.org/files/issues/search_block.patch (1.02 KB)

here is a patch that adds a search block.  works with 4.4.x and should
work with HEAD too.


------------------------------------------------------------------------

June 18, 2004 - 19:57 : moshe weitzman

In order to mark an issue as 'patch', please submit a patch against HEAD
and test it. Moving back to Active.
Also, consider using the form_x functions instead of hard coding HTML
into the block.


------------------------------------------------------------------------

July 10, 2004 - 16:58 : leafish_paul

Apologies for not including a patch here, but for anyone who's
interested, here's my amendment to erikhopp's patch (using drupal's
form functions as suggested):

<?php
function search_block_view() {
    $output .= form_textfield( $title='Search in this site',
$name='keys', $value='', $size=15, $maxlength=128 );
    $output .= form_submit( $value="Go" );
    return "<div class=\"search-block\">". form($output, "post",
url("search")) ."</div>";
}
?>




------------------------------------------------------------------------

July 13, 2004 - 16:10 : erikhopp

Attachment: http://drupal.org/files/issues/search_block_0.patch (764 bytes)

ok.  thanks leafish_paul.  
here is a patch that applies to HEAD.


------------------------------------------------------------------------

July 14, 2004 - 15:05 : erikhopp

forgot to set to patch...


------------------------------------------------------------------------

July 14, 2004 - 15:49 : Dries

The patch looks incomplete to me.  You have to implement
'search_block()' for this work ...


------------------------------------------------------------------------

February 4, 2005 - 19:31 : Steven

The patch is incomplete and uses borky code (the whole $var=value thing
in the search block function is theoretically correct, but practically
stupid). Perhaps the current search_form function should simply be
modified with a width parameter so it can be used in the block too?


-- 
View: http://drupal.org/node/820
Edit: http://drupal.org/project/comments/add/820





More information about the drupal-devel mailing list