Closed (fixed)
Project:
Viewfield
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Dec 2009 at 14:23 UTC
Updated:
3 Mar 2011 at 21:42 UTC
Jump to comment: Most recent file
I'm embedding a viewfield on a content profile. I'm passing %author to the view, but the view doesn't validate it. I've tried most of the permutations of uid or user name to try to ascertain what %author was actually passing, but to no avail.
The fact that I am using a viewfield embedded in a Content Profile http://drupal.org/project/content_profile may have implications as to why this doesn't work.
cheers,
glass.dimly
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | viewfield-HEAD.arg-author.11.patch | 1003 bytes | sun |
Comments
Comment #1
ericg commentedI'm having the same problem. After digging around a bit, I can say for sure that this is an issue for the Content Profile module and not viewfield.
repost this over there and I'll follow up as I work on a fix. For the short term, here's the workaround that I'd suggest (or at least this is what is working for me at the moment):
use %nid instead of %author in your viewfield
in your view, use an argument for User: Uid
in the argument settings section "Action to take if argument is not present: " click "Provide default argument"; in the section "Provide default argument options" click "PHP code" and in the field "PHP argument code:" put $userid = $node->uid;
Comment #2
ericg commentedactually, after a little more digging it does seem to be an issue for viewfield not content profile. I'll post a suggested patch in the next week or two
Comment #3
mherchel@ericG - Did you ever finish creating the patch?
Thanks,
Comment #4
cregar commentedIs there a problem with %nid, too?
I have a view which definitely works with the right nid-argument. but when i edit the content profile the viewfield doesn't appear.
Comment #5
wonder95 commentedI'm having this same problem, too. I'm using Viewfield on another node type where I'm passing %nid and it works fine, but when I use %author, it doesn't get passed at all. I've verified that my view works correctly when the uid is passed, so I know the problem isn't with the view.
Comment #6
wonder95 commentedI haven't fixed this issue, but I thought I'd document my workaround, which was based on #1 above by @ericG.
However, there are a couple problems. The first is that he says to add %nid as an argument and then add PHP code under "Action to take if argument is not present: ". This code will not kick in if there is an argument, so you have to leave it blank in the viewfield settings.
The second problem is the code itself. The code has to return a value, so just putting
won't return a value. In addition, the $node object isn't available there, so you have to get it using menu_get_object(). This code
works great.
It's still not a fix, but it will get around the problem.
Interesting note, though; it does appear that something is being passed to the view when %author is put in the viewfield config, because with the code above, I get no items displayed.
Comment #7
madtI solved problem with %author as an argument by simply marking 'Enable token replacements.' checkbox. I tested this couple of times and it worked for me.
Comment #8
wonder95 commentedThat works for me, too, but it raises a couple questions/issues:
Comment #9
jonhattanSame scenario here: using content profile + viewfield.
as far as I've tested:
1. %uid is not a valid replacement token (even not documented. How did you come to figure it out?).
2. %author is the node author uid. You can verify the view user:uid argument does not works with "Only allow string usernames". The other options accepting user uid are fine.
3. In point 1 I've put token in italics as the usual syntax for a token is [author], not %author. Anyway %author is considered a token in viewfield, and if you are using tokens you need to Enable token replacements.. If not... the argument to the view is "%author" (literal).
So I think this is not a bug report but a documentation issue. Suggestions:
* extend description on Arguments field to:
a) make explicit that %author will pass the author user uid to the view
b) make explicit that %something is a token and will not work as spected although you enable token replacements above.
Comment #10
sunThere's no patch here?
Comment #11
sunThanks for reporting, reviewing, and testing! Committed attached patch.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.
Comment #13
dadderley commentedI have pretty much the same scenario as the original poster.
I cannot get %author to pass to the view.
Does this work for anybody?
Comment #14
glass.dimly commentedworkaround: set the default argument in the view.