如何自定义用户的user资料显示页视图

论坛: 


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?

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.

    Create a view and add a "page" display.  创建一个views并添加一个“page”显示  
    Use "user/%" as the page path.  使用“user/%”作为页面的路径。
    Add a contextual filter "user uid" and select "provide default value" user ID from URL.  添加一个上下文过滤器”user uid”并选择“provide default value”的用户ID。

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.
        
   
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.