How to display ANY view in the advanced profile page in Drupal

Recently I came across a new module in Drupal, Advanced profile. This module is cool because it hooks up with a bunch of other modules and helps you get a really good user profile setup. It also has a nice drag and drop interface for the admin. Using panels, node profiles etc you can create a very nice user dashboard. You can read more about advanced profile here.

Advanced profile is a relatively new module, its still in alpha and therefore has limited display options. I had created a view that I wanted on my user profile page but the module right now supports only 2-3 pre-defined views like buddylist etc. For the some of us who cant wait here’s a small hack on how you can get any view to be displayed in your profile.

  • Create the view you need to display. Choose the export option for the view. This will dump the exported contents on your screen. Here’s what I got when I exported my view.

$view = new stdClass();
$view->name = 'user_regs';
$view->description = 'All Registrations';
$view->access = array (
0 => '3',
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'table';
$view->url = 'user/myregistrations';
$view->use_pager = TRUE;
$view->nodes_per_page = '10';
$view->block = TRUE;
$view->block_title = 'registrations';
$view->block_header = '';
$view->block_header_format = '1';
$view->block_footer = '';
$view->block_footer_format = '1';
$view->block_empty = '';
$view->block_empty_format = '1';
$view->block_type = 'table';
$view->nodes_per_block = '5';
$view->block_more = TRUE;
$view->block_use_page_header = FALSE;
$view->block_use_page_footer = FALSE;
$view->block_use_page_empty = FALSE;
$view->sort = array (
$view->argument = array (
$view->field = array (
array (
'tablename' => 'node_data_field_tracking_number',
'field' => 'field_tracking_number_nid',
'label' => 'Tracking Number',
'handler' => 'content_views_field_handler_group',
'options' => 'default',
array (
'tablename' => 'node',
'field' => 'title',
'label' => 'Status Report',
'handler' => 'views_handler_field_nodelink',
'options' => 'link',
array (
'tablename' => 'node',
'field' => 'created',
'label' => 'Created',
'handler' => 'views_handler_field_date_small',
array (
'tablename' => 'node_data_field_test_status',
'field' => 'field_test_status_value',
'label' => 'Status',
'handler' => 'content_views_field_handler_group',
'options' => 'default',
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'cck_status',
$view->exposed_filter = array (
$view->requires = array(node_data_field_tracking_number, node, node_data_field_test_status);
$views[$view->name] = $view;

  • Save the above contents in a file called Save this file in advancedprofile/advprofile/.
  • Edit advanced_profile.css present in the advprofile directory and add the following contents:(view-yourviewname)

.view-registrations-of-uid .thumbnail {
float: left;
width: 100px;
height: 140px;
border: 1px solid #3192CE;
margin: 10px;
padding: 5px;
text-align: center;
.view-registrations-of-uid img {

  • Edit advanced_profile.module and add the following line to the advanced_profile_views_default_views() .

eval(file_get_contents($views_dir . ''));

Again remember to replace the filename in the example with the .inc file you created.

That’s about it and your custom view will now be available to choose and display in the content display window. This way you can make any view available for the advanced profile module.

This entry was posted in drupal, trivia, tutorials and tagged , , , . Bookmark the permalink.

3 Responses to How to display ANY view in the advanced profile page in Drupal

  1. Michelle says:

    Glad you like the module, but I think you’re misunderstanding a bit. Advprofile ships with a few views that are useful in profiles but it’s not limted to those. You can add any view on your site to the panel. Either go to views panes and create a new pane from the view or enable the legacy view panes module to have every view show up when you add content.


  2. divya says:

    Hey thanks Michelle! I din’t quite understand what legacy panes meant.. and since they recommended not using it for new installations I let the module be…

    Anyways thanks for that! Its big help 🙂

  3. Michelle says:

    Hmm… Where does it reccomend you don’t use it? I suspect the docs need improving, then.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s