Hello,
I have a view that is running php code when the argument is not present.
Action to take if argument is not present ->Provide default argument -> Default argument type -> PHP Code
Until version 6.x-2.0-rc4 my view was working perfectly, but when i upgraded in 6.x-2.0-rc5, the query does not running any more, when the argument is missing. Inside settings of my view i am getting the message "No query was run" when i am pressing the preview button.
Looks that something is going wrong, with default argument type. I changed the default argument type to fixed entry and i inserted a value 2008 (Node created year) at the default argument, but with no result again...
Any advice would be much appreciated!
Comments
Comment #1
sotiris commentedComment #2
sotiris commentedIt would be nice if someone could confirm, the issue with the default argument...
Comment #3
merlinofchaos commentedBe patient. I haven't had a chance to get to this one yet.
Comment #4
sotiris commentedOk, no prob, i can understand that you have a lot of issues to solve, i'll wait for your confirmation.
Comment #5
merlinofchaos commentedI'm also presenting at BADCamp tomorrow, and am focused on trying to make sure those presentations don't suck
Comment #6
merlinofchaos commentedWell, I can't get this to happen on my test system. Is your argument one of the date arguments? If so you may need to remove and re-add your argument. If not...I'm not sure what to suggest.
Comment #7
sotiris commentedYes, my argument is "Node:Created Year". I removed and re-added it, but without any result. When the argument is missing i am getting: No query was run.
In my PHP code i have:
return date(Y);
Comment #8
IngusNeilands commentedSame problem with 6.x-2.1 and 6.x-2.x-dev ( 2008-Oct-30 ).
Configure Argument Date: Date
Default argument type PHP Code => return date(Y);
Mybe there are some problems with PHP code validator ?
Comment #9
merlinofchaos commentedYou know, I just realized that your code has a bug in it. It should be:
Comment #10
dlloyd commentedRunning 6.x-2.1 on Drupal 6.6, I'm having the same problem with defaults set for arguments for Node: Month Created and Node: Year Created. It happens whether I provide the default via PHP code or fixed entry - "No query was run". If I provide arguments via the live previewer or call a page display with an argument specified, it works fine.
Comment #11
ar-jan commentedI get the same as in #10, using default argument: php code:
Like in the original post, using fixed entry: '2008' results in the same error "No query was run".
Comment #12
ocirs commentedI'm running in to the same problem. This problem is easily replicable by downloading and installing the most recent copy of Drupal 6.9, installing the views module and creating a view with "node: created year" as an argument and '2009'(or any other year) as the default fixed argument.
Live preview shows 'No query was run' with basic validation and when I insert 'return 1;' with php validation the argument runs but is missing the argument.
ex.
WHERE EXTRACT(YEAR FROM((FROM_UNIXTIME(node.created) + INTERVAL -18000 SECOND))) = ''
when it should be
WHERE EXTRACT(YEAR FROM((FROM_UNIXTIME(node.created) + INTERVAL -18000 SECOND))) = '2009'
When '2009' is provided as an argument in live preview the query is the latter with the argument.
Comment #13
merlinofchaos commented#12 I tried exactly what you said, and it works exactly as expected. The fixed argument I set gets used in the view both in live preview and normally when used as a block or on a page.
Comment #14
ocirs commentedI've found the piece of code from RC4 to RC5 that cause the problem here
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/views/handl...
By copying that piece of code back in to views_handler_argument.inc, the problem was resolved and everything works as expected.
Does that help?
I'm the latest stable release 6.x-2.2, 2009-Feb-07
Comment #15
jcamfield commentedI am having this same problem, with both fixed entries and PHP code; adding that diff back in had no effect for me.
Comment #16
merlinofchaos commentedHave you tried completely removing the argument and re-adding it?
Comment #17
zbricoleur commentedI'm having the same problem as described above in #10, with 6.x-2.3.
Date field for the argument is Node: Post date
Provide default argument: checked
PHP code: checked
Code provided:
This argument is the second argument for the view. If I supply the date argument in the querystring manually, exactly as it is generated by the code above, it works properly. If I don't--if I supply only the first argument--I get the No query run message on Preview, or Page Not Found on the view itself.
I tried completely removing the argument and re-adding it. Still have the problem.
Also tried the suggestion in #14 and still have the problem.
Comment #18
enricom commentedI was having the same problem mentioned above.
I was trying to use
and
as default values for my two arguments, but I kept getting 'No query run'.
Providing a static value didn't work either.
Using 'current date' as the default value almost worked (at least it queried), but it returns date("Y-m-d") irrespective of the argument type.
Here is the modification I made to handle the different 'Node: Created' date types.
views_handler_argument_date.inc @ line 37
It's not a solution to the general problem which seems to be that default values can't be specified using php, but if all you want is the built-in 'Node: Created' arguments, this solves that.
Comment #19
merlinofchaos commentedSee #350376: Missing return in views_handler_argument_date.inc
Comment #20
andrewsuth commentedI'm using the latest Views 2.5 and am still get this same problem as outlined in this thread. I've checked and tested my PHP code in other places I know it works.
I noticed the patch mentioned above has been applied to
views_handler_argument_date.incin Views 2.5 but it continues to ignore my code inDefault argument type: PHP CodeIs anyone else having this same issue still?
By the way, I'm outputting my View as a Block, so this code is always executed, as explained in the help docs:
EDIT: Solved: I found that when changing any of the PHP code, I then had to flush all caches before it would work properly. I also discovered that the Preview didn't represent what was actually being displayed on the user end.