How to filter view by date?
the view just showing today post, yesterday post will not showing.
if there is no latest post, no post showing.

Comments

vm’s picture

you can add the date to the sort.

how is the view set up ?

mampwamp2’s picture

are you mean add date in argument?
which one should be use?

vm’s picture

could you please provide a screenshot of how your view is set up and a more details as to what you are looking to have views do?

mampwamp2’s picture

thank.. here the screenshot
http://imgbin.org/index.php?page=image&id=9972

the block always show today article, if no article by today,
nothing will show...can this done by views.

How to set this?

vm’s picture

do you have a view set up in the views.module for this?
if so, could you please take a screen shot if the views settings.

upchuk’s picture

I think I understand what you want. You want a block to show only today's articles, if they exist.. If not, to show blank.

You can easily do this with Views by using Contextual Filters.

Create your View block that shows the content you want. At the pager you can set the number of articles to show if there are more articles posted on the same day (today).

Then add a contextual filter of the type Content: Created day and Provide a default value of the type: Current date.

Apply, and test your view.

Hope this helps.

You can follow me on Twitter: @drupalexp or on my blog.

mampwamp2’s picture

the Contextual filters module is that this one?
https://drupal.org/project/context

vm’s picture

contexual filters aren't a separate module. They are built into views ui on the far right hand side.

upchuk’s picture

You'll see it under the Advanced tab in your View.

You can follow me on Twitter: @drupalexp or on my blog.

mampwamp2’s picture

http://imgbin.org/index.php?page=image&id=9989

where is the advanced tab? above is the screenshot of my views.

upchuk’s picture

I see you are using Drupal 6.

You should mention this when you ask for help.

Contextual Filters is the new name for Arguments. So you should add an Argument of the type Node:Created Day.

Then Provide default argument -> Current Date

Let me know!

You can follow me on Twitter: @drupalexp or on my blog.

mampwamp2’s picture

thank very much..
it working now.

one more question,
if there is no post by today, can we print out "sorry, today no post."? on that page?

upchuk’s picture

Yes you can,

Under Basic Settings, edit the Empty Text option. There you can add the text you want displayed if the View shows no results.

You can follow me on Twitter: @drupalexp or on my blog.

mampwamp2’s picture

thank you very much

zakmail007’s picture

How would i do this if i wanted to show all articles from the previous 24 hours?