2

I'm trying to add a list of author's content to a profile2 page. The profile page is separate from the user account page so I can't use get UID from URL option.

1

Using the View Default Argument From Context Module I added this code to it.

function views_arg_context_profile2_view($entity, $view_mode, $langcode) {
  context_set('user', 'uid', $entity->uid);
  context_set('profile', 'pid', $entity->pid);
}

Now there is an option in Views Default Argument to pull the ID from context and I place either user or profile in the appropriate text field and it works fine.

1
  • could you explain this further how you did this? Sep 21 '12 at 4:48
0

You could try this module: http://drupal.org/project/eva. It sounds like using tokens you could probably achieve what you are needing.

I think you could also use page manager/panels to override the profile page and load a context with the author id and pass the context to a view content pane. This probably has a little more overhead and learning curve involved if you are not familiar with panels.

1
  • Entity Views Attach would work except that it adds the information to a field that is attached to the entity -- it doesn't create a separate block.
    – Adam S
    Sep 14 '11 at 13:26
0

If you're on the profile2 page or have access to the $profile2 object, you can access it's owner by looking at $profile2->uid

1
  • It's not an option in the Views UI. I use hook_entity_view to set the variable in the Context object using Context's setter. This way Views has a way to get at it.
    – Adam S
    Oct 14 '11 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.