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 ??
-
1What are you trying to display in the views? terms, nodes... ?– GladiatorOct 21, 2013 at 6:00
-
Also, what do you mean by random? If you are asking for nodes without anything to narrow it down, you are getting all nodes, right? What's unexpected about that? Sorry, I would really like to help you, but I can't understand what you need. Please edit your question to show (roughly in order): 1) What you wanted to achieve? 2) what you did to achieve it? 3) how the effect differs from what you expected?– MołotOct 21, 2013 at 7:04
-
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 ??– Astha chauhanOct 21, 2013 at 8:10
-
@Asthachauhan please edit your question. Data provided in comments will probably not be noticed by people who vote on your question (or vote to close it), and comments may get deleted without a notice in a cleanup process.– MołotOct 21, 2013 at 8:25
-
1Are you trying to display nodes of a particular type? If yes then how many nodes of that type has been created is it 2 or more?– Somya GuptaOct 21, 2013 at 9:02
2 Answers
There is a views setting "Exposed form style", where you can select "Input required" if you don't want results to be displayed by default.
See the attached screenshots:
Then
-
Thanks for the easy solution ROBBY, it worked for me.Can you please tell me why those two random results were shown up? Oct 22, 2013 at 5:07
-
No worries. Best to select an answer as being correct if there is one that is correct. It helps keep the list of "unanswered" questions on the site a little bit smaller and lets people see at a glance if a question they are interested in has an answer.– roobyOct 22, 2013 at 10:31
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.
Alternative solution
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.
-
Thanks for answering ARJAN but if I make filters required the view is not getting saved and throwing 'No valid values found on filter: Content: Type' error. Oct 21, 2013 at 11:48
-
@Asthachauhan: yes, I can confirm that this is a problem with this particular filter. I've updated my answer; I'm not sure yet if there's another way.– arjanOct 21, 2013 at 12:21