Hey there,

I would like to insert a couple of views as droplets on my Mysite install. The thing is that I created a new "format" plugin for all mysite content that I use for the rest of the content. That new format is an ajax preview pop up box that shows a list of titles and an ajax pop up box when the user clicks on a title, instead of going to the node directly.

To keep the look consistent on all content blocks I would love to format the views droplets in the same fomat than the rest of the content... Do you think this is a realistic feature request?

Thanks,
Patchak

CommentFileSizeAuthor
#2 preview.theme_.txt1.98 KBpatchak

Comments

agentrickard’s picture

Status: Active » Postponed (maintainer needs more info)

I do not understand the request. How are the views droplets different so that your format cannot be applied?

I need more detail to answer.

Can you attach the format plugin file here?

patchak’s picture

StatusFileSize
new1.98 KB

Hey there,

Well the views droplets seems to be displayed in their native views format, for example table, list or teaser list. My own custom format is a list block, and when you click on a link it pop up a window with the teaser info in it.

SO I would love to be able to make custom list views and display them with that custom format on the mysite page.

Hope this is clearer, here is attached the format in question. (rename it to .theme to use it.)

agentrickard’s picture

Version: 5.x-2.15 » master

I'm looking at the code and guessing that your issue is this part:

    // this is a droplet, so output the content
    else {
      $output = theme('mysite_droplet', $element['content']);
    }

The $element['content'] is already formatted by the native Views handler. I think retheming the view itself, using Views Theme Wizard, is your best approach.

Also remember that you are not required to use theme('mysite_droplet', $element['content']) here. You could use a different theme function.

The question from my end, I think, is "do you need more information about the View in order to make a theme selection?"

patchak’s picture

So it's not possible to override the views theme with a mysite theme without actually retheming the view? What would be nice is to only be able to tell mysite to override this view's theme with a selected format only when the view is presented in a mysite page.

ps. have you tried the new format I attached? do you like it?

agentrickard’s picture

I get it. You would need more information about the View passed to the format layer.

The key may be in this function in droplet.inc:

function mysite_type_droplet_view_content($droplet) {
  // for blocks, the key is stored as "module|delta"
  $view = views_load_view($droplet->key);
  $output = views_build_view('embed', $view, $args, $view->use_pager, $view->nodes_per_page);
  return $output;
}

The question is: How does view_build_view() behave, and what additional arguments could you pass to it?

I have not tried the new format yet.

patchak’s picture

Hi, could you give me more details on what you mean? Sorry for being dense, but I'm not sure how I could theme the view separately for mysite and for the normal view,

thanks,
Patchak

agentrickard’s picture

I am not sure either. I think it would be possible to pass a variable in the $args array in the function call:

views_build_view('embed', $view, $args, $view->use_pager, $view->nodes_per_page);

At the end of views_build_view() is the following code:

  foreach (module_implements('views_pre_view') as $module) {
    $function = $module .'_views_pre_view';
    $output .= $function($view, $items);
  }

  $view->real_url = views_get_url($view, $args);

  $view->use_pager = $use_pager;
  $view->pager_limit = $limit;

  $output .= views_theme('views_view', $view, $type, $items, $info['level'], $args);

  // Call a hook that'll let modules modify the view just after it is displayed.
  foreach (module_implements('views_post_view') as $module) {
    $function = $module .'_views_post_view';
    $output .= $function($view, $items, $output);
  }

You may be able to do what you need by implementing either a mytheme_views_pre_view($view, $items) function or a mytheme_views_post_view($view, $items, $output) function.

A small module would be required, and you would want to check the following condition:

function mytheme_views_pre_view($view, $items) { 
  if (arg(0) == 'mysite') {
   // Make your changes here.
  }
  return $view;
}

I am not certain that this will work unless the $view is passed by reference, and that does not appear to be the case.

You might also be able to override the default theme using the above conditional.

agentrickard’s picture

I finally looked at the new format file, and it seems to rely on other files that are not present.

Especially lines like these:

    $when_show_nodeteaser = variable_get('mysite_tools_nodeteaser', 'onmouseclick');
...
          'onclick'=>"return mysite_tools_show_nodeteaser(this, " . $element['nid'] . ");", 

Also a little change to this function in the API:

function mysite_theme_preview() {
  $name = t('Headlines list with preview');
  $output = '<div class="mysite-sample mysite-content">';
  $output .= '<ul>';
  $output .= t('<li><a href="#">Sample headline</a></li>');
  $output .= t('<li><a href="#">Sample headline</a></li>');
  $output .= t('<li><a href="#">Sample headline</a></li>');
  $output .= '</ul>';
  $output .= '</div>';
  return array('format' => $name, 'sample' => $output);
}
agentrickard’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)