I have created a view to display node's title and added exposed filter for filtering content. When the view page is loaded it is returning two nodes , I do not know on what basis it is returning those two nodes.I want no result should be displayed until I select some value in filter.Please suggest ??
When you add a filter under Filter criteria, and select "Expose this filter to visitors, to allow them to change it", also check the "Required" checkbox. This will make the view not show any results until this filter has been submitted.
Update: this works generally (e.g. with the operator 'Contains' on a field), but not when the exposed filter is Content: Type. You can work around the error by checking "Limit list to selected items" and checking the content types that may be selected. However, now the view will initially be filtered on the first content type of the select list, instead of empty. See this Views issue.
You can use the approach outlined here:
- Choose Filter type to expose: Grouped filters
- Deselect 'Optional'
- Create a default option, e.g. a label 'Choose a content type', operator 'Is not one of' and select all available content types. This will return your empty view.
- Create a label for each content type you want to expose and use 'Is one of' operator, with the corresponding content type checked.