I don't even know if what I want to do is possible, so bear with me. My set-up:

I have a View Context that accepts an author UID argument from the Panel context, and then displays content created by that author UID. This View Context has been added to the user/%user system Panel in Page Manager. This allows me to create a custom CTools Plugin that takes that View Context, gives it an additional parameter (content type) to filter by, and spit out the final view programmatically.

The purpose of this is to create many small reusable lists of content in different content types that a specific user has authored, with custom more links and other mark-up around those lists. (I.e., we might show 3 of each content type on a profile page, and if they have created more than three, we link to a different user/%user/this-content-type page that has the full list of that type and a proper pager.) The custom header/footer/more links, the ability to insert additional custom copy or code between lists of nodes, and manual ordering of content types are the main reasons why I'm not simply using Views' default grouping function.

The relevant View rendering code in the CTools Plugin is something like this:

function custom_list_render($subtype, &$conf, $args, $context = NULL) {
  $block = new stdClass();

  if ($conf['type']) {
    $view = views_content_context_get_view($context[0]);
    $view_output = views_content_context_get_output($context[0]);
    $plugin = $view->style_plugin;
    $rows = array();

    foreach ($view_output['view']->result as $row_index => $row) {
      if (custom_content_type_match_function($row, $conf)) {
        $rows[] = $view_output['rows'][$row_index];

    $output = theme($plugin->theme_functions(),
        'view' => $view,
        'options' => $plugin->options,
        'rows' => $rows,

  $block->content = $output;
  return $block;

This code works. There's some additional admin form work going on that selects and saves the $conf['type'] for each iteration of this plugin that you add to a panel.

Right now, the view output is spit out as rendered entities in a custom view mode. I'm wondering if it's possible to alter the View Context at the plugin level so that when you add this plugin to a panel, you can also select which custom view mode you want the rendered entities to render as. (Think Teaser vs Full vs Block.) If so, at what point do I need to disrupt the view (I imagine before views_content_context_get_view?) in order to pass it the new view mode, and how?

Alternatively, could I somehow pass an additional custom argument to the view (e.g. "ctools_view_mode" or something) and then use hooks_view_pre_render to change the view_mode?

Thanks in advance!

Running: Most recent iterations of D7, Panels, Views.

  • 1
    I'd point you to the Panopoly Magic module as a reference since it does something very similar but with Views Content panes. You'll need to form_alter the form that adds the context (hook_form_views_content_context_view_settings_form_alter(), I think) so that the user can select the view mode, add a submit handler to store your value somewhere ($form_state['conf'] perhaps) and then implement hook_views_pre_view to swap in the desired view mode. Not making this a real answer since I'm a little light on the details.
    – Aaron
    Aug 26, 2015 at 1:17
  • @Aaron Will probably go with alxp's workaround but this is good to know, thank you!
    – Phire
    Aug 26, 2015 at 1:35

1 Answer 1


I think you can bypass Views and get what you want with a content type plugin that does a query for the nids you are interested in, then passing that array to drupal_load_multiple(), then passing the result of that call to drupal_view_multiple().

drupal_view_multiple can take whatever view mode you want as a parameter, and will return a render array that you can just throw at whatever custom extra theming you need to do before displaying it.

  • I assumed the OP needed a Views context plugin because s/he wants to re-use the Views results and settings in multiple places throughout the Panel. If that's not needed then the OP should definitely use something like your totally custom approach or, if more Views-specific functionality is desired, then a Views Content Pane with modifications.
    – Aaron
    Aug 26, 2015 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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