I have a view which should show all news articles of a certain year. It should take arguments or default to the current year. (The exported view is attached to this issue.)
The view works perfect with arguments in the url, but the default argument doesn't work.
First, I tried both a fixed entry (2009) and php code (return date('Y');) for the default argument. The validator was set to Basic validation. In both cases, the result is the 'Action to take if argument does not validate' as chosen in the Validator options fieldset. The query info in the live preview says "No query was run".
Next, I switched to PHP code validation and entered return TRUE; as validation code. Again, I tried both a fixed entry and php code. I still got empty results, the difference being that a query was run this time:
SELECT node.nid AS nid,
node.title AS node_title,
node.created AS node_created
FROM drupal_node node
WHERE (node.status <> 0) AND (node.type in ('news')) AND (EXTRACT(YEAR FROM((FROM_UNIXTIME(node.created) + INTERVAL 3600 SECOND))) = '')
ORDER BY node_created DESC
Note that the argument value is empty in this query.
It looks like a bug to me, but maybe I'm just doing something wrong. Thanks for helping!
| Comment | File | Size | Author |
|---|---|---|---|
| view.txt | 5.22 KB | marcvangend |
Comments
Comment #1
marcvangendI got my view working by using a "Date: Date Node: Post date" argument and setting the granularity to year. My problem is solved, but I'm leaving this issue open because I still think it's a bug that the Node: Created year argument suggests that it accepts a default argument, which doesn't work.
Comment #2
deshilachado commentedIf you are using date 6.x-2.0 then this might be a bug in the date module and not in views.
There seem to be some problems with default arguments.
Comment #3
deshilachado commentedNo, sorry, the Node created date doesn't have anything to do with the date module.
Comment #4
Andrew Schulman commentedI confirm this problem. I have a custom date field and want to filter my view on date >= now. I choose Operator: is greater than or equal to; Default value: now. But this always fails:
so that it seems to be treating the unselected date fields as 2009-01-01. (I also don't know where the -18000 sec. comes from, but I guess that's a fudge factor and a different issue.)
which is right today, but won't be right tomorrow.
So no matter how I try to enter it, some value always overrides the default. I've tried disabling Javascript and it didn't help.
I want to show coming events, and Views seems to offer the right options to do that, but at the moment I'm completely out of ideas as to how to make it work.
Thanks,
Andrew.
Comment #5
marcvangendAndrew, can you post some of your view code (export the view and look for the
$handler->override_option('arguments'part), to make sure we're talking about the same thing here?In my case, this argument does process a default value correctly ('date_argument' type):
While this one does not (created_year type):
Comment #6
Andrew Schulman commentedStrangely, there's no
$handler->override('arguments')part of my view. Here's the part that seems to be relevant:Comment #7
marcvangendOK, your bug concerns filters, mine is about arguments. They are both date-related, so they might share a common cause, but for now, I think it's better if you create a new issue for your problem. I'm changing back the title.
Comment #8
Andrew Schulman commentedOK. Following the instructions for reporting issues in Views, I went to report this at the Date module and found my issue already there: http://drupal.org/node/386406 , with lots of others suffering from it, and a fix already available in -dev.
Good luck with your issue.
Andrew.
Comment #9
marcvangendThanks andrew, good to see that you found the source of your problem (and that it's almost solved :-)).
Comment #10
David Stosik commentedHello,
I'm experiencing a bug close to the description.
When using "fixed" or "PHP" to provide a default value for the argument "node: created year", it is not taken into account, and "the query is not executed".
I had this bug with 2.2, updated to 2.3 and the problem is still here. :)
I hope this will get corrected soon...
Comment #11
merlinofchaos commentedThis is fixed in 2.4. See #350376: Missing return in views_handler_argument_date.inc
Comment #12
marcvangendThanks Earl, it's great to see yet another release with so many fixes and improvements. I can't imagine Drupal without Views anymore.
Comment #13
agenciadroopi commentedI have tried using the disable Archive view, enabling it and then change the Node: Created year/month to Node: Created Year, so I have found that I need to update the page display too, that was pretty silly error