By eviljoker7075 on
Hey everyone, I was just wondering, is there a module that will let me edit the advanced search for my site to include extra fileds created with CCK?
Also - how do I add the link to 'advanced search' under the search box in the search block?
Comments
Is there nothing like this?
Is there nothing like this?
No link between Search and CCK
As I understand it there is no link between CCK and the standard site search, though I believe that it might be possible to write hooks for this (no idea exactly how though).
I think at the moment that the only way to do searches on CCK content is to use the Views module with selection criteria set to be entered at runtime.
Thanks, I think that is what
Thanks, I think that is what I may have to do...
Probably just be better to
Probably just be better to use the google site search thing
Here's how I linked directly to advanced search
I, too, searched for forums for the answer and found none, so I hacked (and I used this term heavily) a way to do this. I thought I'd share, with lots of disclaimers that I am not a PHP pro and have no idea how elegant this solution is (or more likely, not). But, it works.
You need two parts. Firstly, you have to create an anchor at the actual advanced search area on the search page. Here's how I did it. Open node.module and find this part:
You're going to replace this with a conditional statement to look at the incoming URL (we'll get to that in part 2) and to figure out if it should set an anchor or not. It is also going to tell it to display advanced search uncollapsed if the intent is to link directly to advanced search. Here's what you replace with:
The only thing I could not figure out how to do is how to eliminate the second little black arrow that this will generate to collapse/uncollapse the advanced search area. It doesn't affect the functionality, so i decided to live with it...maybe somebody else can figure this one out? Ok, now part 2. Open template.php in your theme. We're going to add a function:
This code renders the search form and adds the actual link underneath it. If your search block is called something else, replace "function phptemplate_search_block_form" with "function phptemplate_whatever_the_name_is." That's it. Hope this helps somebody.
Lebachai
Using Javascript instead of PHP hacks to link
I've done something similar to this, but I just added a custom Javascript file to my theme and then the link I needed. The Javascript contains:
And then I just need to add a direct link to:
That's good enough for me.
You'll kick yourself ...
The way to stop a fieldset being collapsible is to set '#collapsible' to FALSE (in the same place you're setting '#collapsed').
Seriously.
--Andy
Developing Drupal websites for Livelink New Media
++Andy
When the right solution is hard
King Andy is right.
Changing anything in node.module is very wrong.
Using a link and a JavaScript to force open the advanced search is bad as well.
You should tell Drupal to keep it open at all times:
Sadly I have no idea where this code should go to have an effect on the search/node-page.
Anyone?
How to collapse fields
Put this in your template.php file
Another way to alter forms is to have a function like this:
This one will expand the form fields supplied by the scheduler module and suggest that the new story you are adding will debut 1 minute past midnight.
FWIW,
MauMau
Thank you for your
Thank you for your explanation, it helped me quite a bit.
Is there a way..
Is there a way to do this correctly in Drupal 6 MauMau? I tried implementing this in template.php and then cleared the cache, but it didn't work.
Is there something I was doing wrong?
=-=
I think drupal_render was changed in Drupal 6.x
Dear Lebachai, I'm
Dear Lebachai,
I'm using drupal 4.7 and B7 theme.
In that case, the template.php that you mean is page.tpl.php file?
I found search_box function in other themes but not in my B7 theme.
Can you please help me where exactly should i put the above function that you suggest.
Thanks much in advanced for your great help.
template.php
Template.php is a file that exists as well, and it is not the same as page.tpl.php. If it's not in your theme's folder, then I guess you can create it yourself with the said functions.
However, if your page.tpl.php doesn't have a searchbox, than I guess that no search box will show up on your pages anyway. So you will want to include the searchbox in your page.tpl.php. Probably the easiest way will be to copy the code that includes the search box from one of those other themes you mentioned.
Cheers,
Jefke
Thanks so much for your
Thanks so much for your prompt reply.
I found template.php in other themes as you mentioned.
But in my theme B7 there is no template.php but search box is still on the front page.
I used B7 green theme.
Do you have and idea where I can I find that search box coding?
=-=
For the B7 theme the searchbox is coded into page.tpl.php
Easy way add the link to 'advanced search' under the search box
(Using Drupal 6.x)
I found this was a case of not seeing the forest for the trees. In my attempts to find a complicated answer for this, I found this easy solution that works.
Copy the search-block-form.tpl.php (from module/search) to your theme directory.
The file is pretty basic with the following code:
So I added in a line of code to get the following (wrapping the new link for easy theming):
And now I have a link in the search block that links straight to the advanced search page.
I don't think it is posssible however to add an argument to this link to auto-expand the 'advanced search' field group.
doesn't work for me
I did exactly as described:
1. copied the search-block-form.tpl.php (from module/search) to my theme directory (sites/all/theme).
2. dropped your code into the exact spot, as in your example above.
3. Saved the file.
Cannot see any difference.
4. flushed all chaches to be safe.
Still no change.
Any ideas?
forgot to mention, I use
forgot to mention, I use drupal 6.10
=-=
try visiting administer -> themes to clear the theme registry.
didnt help
I also went to administer > performance and cleared all chaced data, which didn't help either.
Anything else I can try?
Trying to get the link?
Are you trying to get the link to the Advanced Search? If so, do the following:
Go to /your/site/theme folder, and look for "page.tpl.php". Perform a search for if ($search_box), and you will see
<?php print $search_box ?>. Replace that entire line with the following:<?php if ($search_box): ?><div class="block block-theme"><?php print $search_box ?><br /><a href="/search/node">Advanced Search</a></div><?php endif; ?>Save this, and then refresh your page.