Drupal: can I specify a View for my search results? - drupal

I have a "Search" field in my website and I was wondering if I can assign my View to the search results, instead of using the default list.
Is this feasible ? How ?
thanks

It is possible to handle the search output by a view using the default search forms without exposing filters:
create a view of type content which displays all content types, display page
set Path: /search/node/%
add Contextual Filter "Search: Search Terms", then set "Provide default value" and "Raw value from URL" and "Path Component" to "3".
Now, every time you search for a node your view gets called instead of the default search result page because it is using the same path than the default search. The % is the argument which is handled by the Contextual Filter. Do not forget to set the filter to the 3rd component of the path which is the placeholder "%".

You can replace the default Search with a Views search instead. I haven't done this personally, but from what I've read it sounds straight forward. Create your "Search" View, then display it's "exposed filter" form instead of the default search form. More details here... http://groups.drupal.org/node/18582
Or, if you just want to make the search results look different, you can simply theme them, instead of using Views to do the searching. You can also control what fields (CCK and such) get displayed in the search results on the Display Fields > Search tab when editing the content type. I don't know the name of the template file for themeing search results of the top of my head, but if you have Theme Developer installed you can easily figure this out.

I've actually found the item "Search" in my Filters options in Views. I dunno how I could ignored it before. It actually exists, and works quite well. Solved.

You can use views to do search with exposed filters etc, but this is not a functionality that you can put on the search you have already. You can create a block in your search view and with theming replace what you got now with it instead.
This probably requires some work since the search box is usually not located in a region.

Related

customize simple search alfresco community 5

Alfresco simple search field searches on document content and folders as default.
Because I'm thinking of using a tag taxonomy I would like to default the simple search field to only search on tags without using the "TAG:" prefix and exclude content and folders. Content and folders can stay as a search option in Advanced search.
The default query looks like this:
cm:name cm:title cm:description my:authorisedBy
ia:whatEvent ia:descriptionEvent lnk:title
lnk:description TEXT TAG
Can anyone give me an idea how this query can be modified only to search on tags?
I'm going to assume that by "simple search" you're referring to the search box in the header bar displayed in Share. This is rendered by the Aikau widget alfresco/header/SearchBox and provides a number of options for customizations.
I think that your best option is going to be to extend the default widget with your own version and override the generateSearchTerm function. This will allow you to take the term provided (e.g. whatever the user has entered into the search box) and manipulate it with the additional advanced search text before it is used in calls to the search REST APIs.
This old blog post provides and example of extending a widget, however you should use the approach outlined in this blog post to add your custom package (rather than editing surf.xml directly)

plone: "to the top of the page"-link at the end of a collection list

how can I add a "to the top" link at the end of a collection in plone?
This collection is in a collage. I thought of adding the article type "page" in a new row where I could use the HTML-Editor and use there an internal link to the top of the page.. But it seems inconvenient to me.
Isn't there a better way?
A very simple way could be using the Plone inner feature of the document_actions (a tool still available but not used anymore from Plone 4.0 and up).
Go to ZMI, access the portal_actions tool, the document_actions. Now add a new "CMF Action" from the form on the right.
The important information for you is the "URL (Expression)", that must be something like string:#youranchortarget. To fill every other field copy from existing actions.
If you need this link only for a content type or something like this, just play with the "Condition (Expression)".
Links inside this tool are displayed in the plone.abovecontenttitle.documentactions viewlet.
If you want the link on every "page" item, then you could customize the default view's template.

Search forms linking to actual search page

I have created a search page uising exposed filters and views module. The user can choose from different values in order to get a table with specific results (returning node fields). This page is located under mysite.com/search. The problem is that I would like to put a simplified version of the search form on my homepage (lets say just the keyword search box + one or two checkboxes). This can be a block or a view. When the user presses the search button I would like to redirect him to the search page and show the results. Here the user shall be able to refine his search in an ordinary way. I guess this can be achieved by HTTP GET parameters and pointing to the actual search site. I was wondering however if I could do it without hardcoding the forms on my homepage, i.e. by using views, blocks, etc. I hope this makes sense. Any help will be appreciated.
Edit
The end result is that you want to have one form bring you to the search results page, and another advanced form on the search results page itself. This solution accomplishes this by creating two identical views with different filters for each form.
When someone uses the simplified form, they're taken to example.com/search, and when they're on that page and use the advanced form, they're taken to example.com/search/advanced. Because the views are identical with similar paths, the end user won't know the difference.
Here's how to accomplish this:
Create a view for the search results. Use the default display to set up the search results however you want. For filters, only put in automatic filters: don't put in the stuff you want the user to be able to filter by.
Create a new page display in that view. Give it a path of search. This is going to be the results page that a user hits when they use your simplified search form.
In this page display, override the filters. Set up and expose the filters you want for the simplified search form.
Override Expose form in block in the Basic settings for this display and set it to yes.
Create a new page display in the view, and give it a path of search/advanced. This is going to be the results page that a user hits when they use the advanced search form.
Override the filters for this display, set up and expose the filters you want for the advanced search form.
Override Expose form in block in the Basic settings for this display and set it to yes.
Now, you'll have two view pages, search and search/advanced, and two blocks, a simplified search form and an advanced search form.
Go to the block administration, and enable the simplified search block. Use the path specific visibility settings to set where you want the simplified search box to appear.
Now, enable the advanced search block. Use the path specific visibility settings to set the visibility to:
search
search/*
Let's say you wanted to create another simplified search block with a different set of filters (let's call this alternate). You can do that too: create another page display in your view as you did in steps 2-4 but instead of using the path search, give it a different path: search/alternate. You can add as many simplified forms with different filters as you want, and they'll all have the advanced search form and the same results when you use them.

Drupal, Views: Search FIlter, how can I ignore some nodes?

I'm using "Search" exposed filter in Views (DRupal):
It works great, however I would like to ignore a specific node, if it is possible, and always display it, regardless the filter options.
how can I do that ? Is possible to specify the Search filter for only a specific content type ?
thanks
Here's what to do:
Add a new display to your view that is an attachment view. In the attachment, override all of your other filters etc and set up the view so that it just loads the single node that you want. Attach this view to the top or bottom of your search view as required.
In your search view, add an argument of node id and hard code a default argument that is the id of the node you display in the attachment. Exclude this argument from the view.
Finbarr's answer is pretty solid. The one thing its missing is the answer to whether you can exclude a specific content type from the search view... yes, you can.
On the display that is your search view, add a Node: Type filter and select "Is not one of" and the content type you want to exclude.

Theming the default search results page in Drupal

I'm trying to customise the mark-up of the default search results page in Drupal 6. Specifically I'd like to remove the search box and the title from the page - I know I can hide it with CSS, but I'd rather it wasn't rendered in the first place.
Ideally, in the same why that you theme a particular content type node by copying the node.tpl.php and renaming it to something like node-blog.tpl.php and then amending the mark-up accordingly - is there an equivalent way to do this for the search results page?
How you get the search box determines how you can hide it. Generally search boxes come from two places.
A block, created by views or some search module.
Defined / created in the theme itself.
How do you remove those?
A block is easy to remove, as you can in it's settings select which pages to display it on.
If the search box is created in the theme, it's a bit more tricky to remove. You have to find out what it is called, when it is defined which should happen in the template.php. Then you need to make a preprocess_function in your theme, where you with some logic, can remove the variable or set it to an empty string.
Alternatively, you could create a custom page.tpl.php for your search result page, where you exclude the search box, when it is printed in the page template.
So while it can be done, it requires some work in the second case if you want to purify your markup.

Resources