2

I've got a view I want to embed in a user profile page (A list of nodes that are associated with the user). The view is already working correctly.

Is the best way to do this to simply make a region in the theme that shows up only on the user profile page and then add the block view to that region?

To complicate this more, I have some pagination that should work with the view that is in date form (they could click "january 2012" or "february 2012" or just "2012" and is separated from the main view by some other content/markup. Do I somehow make two views? One for the content and the other to manage the links back to the page for which the main view can determine which content to show?

2

I think adding the view into a region is the simplest way to do this. The main problem with this would come if you wanted to show the view 'inside' the rendered user. There are a couple of modules that could also help with this:

EVA (Entity Views Attachment) - This module allows you to create a view that becomes a field in an entity. You can then enable it in the field display area for the user entity.

Panels - This is a hefty module and probably overkill for what you need. Unless I was using it elsewhere I probably wouldn't use it for this.

6
  • Create a view and add a "page" display.
  • Use "user/%" as the page path.
  • Add a contextual filter "user uid" and select "provide default value" user ID from URL.

You are done. This view overrides each user's profile page.

You can also add another display "attachment" to this view. Or add another views block as a view area into the footer of that view.

  • Because this is a page view, you don't need the "provide default value" setting because you are on a page that has the uid and if it doesn't, then the default UID from URL will not work either. – rooby Aug 4 '14 at 8:20
  • In my experience this solution causes problems. If a logged out user goes to the /user page to log in you get a bunch of errors like "Notice: Undefined offset: 1 in _menu_translate() (line 777 of includes/menu.inc)." and Notice: Undefined offset: 1 in _menu_translate() (line 783 of includes/menu.inc). because of issues between the normal drupal user menu router and the views one. – rooby Aug 4 '14 at 8:22
  • @Sinan Erdem Can this be done with blocks instead of pages? – Sam Jul 11 '15 at 18:27
  • Sam, you could go with Panels then. A panel page can also override a user page. Then you could add any block to that panel. – Sinan Erdem Jul 20 '15 at 17:44

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.