Hi All,
I have a CCK type with field_day and field_month, which have nodes per day of the year.
I would like to have a view that shows only today's nodes, according to day of the month and month of year.

Unfortunately I couldn't find a way to make this. I thought viewsphpfilter.module will help, but coding it is more then I wanted.
Getting into Views API is something that I try not to do in this case...

Any idea ?

Comments

matt_harrold’s picture

You could use View arguments to pass the month and day into the view.

Then your problem becomes generating a link that supplies the right day and month:

  echo "<a href=\"/yourview?field_day=".date("j")."&amp;field_month=".date("n")."\">Today's Nodes</a>";

This is ONE way to work around your problem without extra modules.

Anyone know a better solution?

shushu’s picture

I love Drupal's hooks !
I've found out View module implemented a hook named hook_views_query_substitutions, which allows me to make changes in the SQL query before it is being executed.
So the solution was to select some code word and preg_replace it. Amazingly easy, although with a little coding, but very elegant.

function hook_views_query_substitutions($view) {

	if ($view->name == "my_view_name") {
		$today = getdate();
		return array("UPPER('TODAY')" => $today[mday], "MONTH" => $today[month]);;
	}
}
matt_harrold’s picture

I am grabbing this snippet and giving it a go. Much more Drupal-like than my suggested hack.

timothymedia’s picture

So, where do you put all this code? I have the same problem you had.