Pass UID as argument into views droplets

Owen Barton - December 21, 2007 - 14:40
Project:MySite
Version:HEAD
Component:- Type plugin
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

Often you want views droplets to be customized appropriately for the current user. Sometimes you can use a 'current user' filter for this, but that only works if users are only allowed to see their own MySite (otherwise they see a droplet customized for them on another users MySite page), and sometimes only an argument is provided by the module you are pulling content from (rather than a filter).

This patch passes arg(1) - the UID of the MySite page being viewed (often the current users UID) into the view, and also adds it to the 'read more' link for that view.

This is relatively safe, as any views with no argument configured will simply ignore it. This could, however break views that are relying on MySite passing no argument in (e.g. because they have taxonomy IDs are the first argument, and only every want to show the default 'no argument' view in the droplet). If we want to support these types of views (without people needing to clone them) we will need to add an option to enable/disable argument passing, but then we are in danger of heading into token or panels context type functionality which could be feature creep for what we need here.

AttachmentSize
druplet_uid_arg.patch1.5 KB

#1

agentrickard - December 21, 2007 - 23:25
Version:5.x-2.15» HEAD

Right. This may be a single use solution. It is, however, related to http://drupal.org/node/200945.

I think we may have to pass the Droplet content to a hook to let other modules make modifications on-the-fly. Otherwise, we have to enable argument or token replacement logic when creating the Droplet.

Filing against HEAD.

#2

agentrickard - January 5, 2008 - 20:40

Does http://drupal.org/node/198904 solve your issue as well?

#3

Owen Barton - January 7, 2008 - 04:21

Added a comment over there - I think that passing an argument is still preferable.

#4

patchak - April 23, 2008 - 17:03

This is great, would it apply to mysite v3 ??
Patchak

#5

agentrickard - April 23, 2008 - 21:52

The patch above should apply fairly cleanly. You might get an 'offset' message, but you can ignore that.

#6

patchak - May 3, 2008 - 18:36

I applied this patch on mysite version : 5.x-3.0 and it seems to be working, as the right argument is passed.

I get this error on the mysite admin section tho:

# warning: include_once(sites/all/modules/mysite/plugins/types/droplet.inc.inc) [function.include-once]: failed to open stream: No such file or directory in /var/www/html/www/yelp-like/sites/all/modules/mysite/mysite.module on line 3423.

# warning: include_once() [function.include]: Failed opening 'sites/all/modules/mysite/plugins/types/droplet.inc.inc' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/www/yelp-like/sites/all/modules/mysite/mysite.module on line 3423.

It seems to be working at it's pretty cool!!
Patchak

#7

agentrickard - May 4, 2008 - 14:41

That error means that Drupal is looking for a misnamed file droplet.inc.inc should be droplet.inc.

Check the names of the files in your plugins/types directory.

This is not normal behavior and may be due to changes you have implemented.

#8

B747 - September 2, 2008 - 12:23

I am getting the same error as patchak after applying the patch, so I can only assume it's an error with the patch. Anyone care to shed some light, please?

#9

Rival24 - September 17, 2008 - 14:43

I'm having exactly the same problem and I'm can't find any reference to droplet.inc.inc in any of the other mysite files.

I'm not entirely sure if my interpretation of this patch is correct. If a bunch of users create a page with a couple of droplets, and I'm going to visit a page other than my own (with a buddylist droplet for instance) I don't want to see the stuff that applies to me. I want to see the buddies of the person that created the site. Is this correct?

Rival24

#10

agentrickard - September 17, 2008 - 14:50
Status:needs review» needs work
 
 

Drupal is a registered trademark of Dries Buytaert.