Download & Extend

Views row plugin broken, no render function

Project:Heartbeat
Version:7.x-1.x-dev
Component:User interface
Category:bug report
Priority:major
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hello,
views_plugin_row_heartbeat_view is missing a render() function, it has a pre_render but no render function. I causes problems with the current views version. Can anyone confirm this?

Notice: Undefined index: theme in views_plugin->theme_functions() (Line 500 of  /sites/all/modules/contrib/views/includes/plugins.inc).

Comments

#1

Yes. Same to me.

#2

Status:active» needs review

This should fix the problem.

AttachmentSize
viewsfix-1322442-2.patch 494 bytes

#3

Status:needs review» needs work

'Delete' works weird, commenting doesn't work. Comments below are not shown.

Edit: This means that javascript is not loaded. I have loaded it, but there is problem with html structure. JS in Heartbeat.js looks for some structure, which is not the same as Heatbeat default streams. I'm trying to fix this.

#4

Now heartbeat properly registers missing views-view-row-heartbeat.tpl.php file. I think everything else should do template_preprocess_views_view_row_heartbeat(). But it is somehow not called. I have tried this for last hour. No chance. Anyone can help? It is really hard for me to write and debug code for Views. First time doing.

AttachmentSize
viewsfix-1322442-2.patch 1.16 KB

#5

Its really weired why the proeprocess hook is not loaded. Meanwhile I help my self out by adding the js and css in the view render function

<?php
function render($row){
     
drupal_add_js(drupal_get_path('module', 'heartbeat') . '/js/heartbeat.js');
     
drupal_add_css(drupal_get_path('module', 'heartbeat') . '/css/heartbeat.css');
   
$activity = heartbeat_activity_load($row->heartbeat_activity_uaid);
    return
drupal_render(heartbeat_activity_view($activity));
  }
?>

#6

I tried same way to add css and js. CSS works. But try commenting. AJAX doesn't work.

#7

+1

#8

Appearantly views has changed a bit since writing that row handler. I 'm looking into this.
Any other useful hints?

#9

Status:needs work» needs review

For me the patch in #2 just works. The delete button does its job, the comment works, the css and js is loaded and triggered ...
I have all latest dev modules installed with the patch in this issue. (Heartbeat, Ctools and views).
So here I don't know why it works for me and it does not for you.

The fact that "views-view-row-heartbeat.tpl.php" does not work anymore (and the preprocessor for it) is normal as the patch does the heartbeat_activity_view itself and does not use the views template suggestions anymore. I thought that was a well considered idea of @Toktik :) I think it's the best way as does should trigger all normal heartbeat behavior. E.g. the attachments like comments and flag links will work now.
I must say for Display Suite layout is triggered by that shouldn't make much difference.

I will wait on some extra feedback as heartbeat does it's entity implementation a bit better lately.

#10

Using the patch in #2 works if you use the heartbeat activity row style but choosing any other row style kills the js. I was hoping to use views relations to pull in extra fields that rules cant access but with heartbeat activity row style thats not possible. My workaround has been embedding a view in a ds custom field in the relevant heartbeat template but that feels like a dirty way of doing it.

Perhaps this is by design, in which case yes, it works. But for me it feels that being able to only use heartbeat activity row style defeats a lot of the purpose of using views with heartbeat.

#11

The row style plugin provides extra functionality.
When choosing fields, you will only have the fields as is and nothing more.

So we have the problem of your use case imho. Can you explain what you are trying to achieve in detail and I promise I will give you my opinion on it. If It wouldn't be possible with heartbeat as such, and the use case is defined in a general manner, I'll try to do something extra when using fields.
But I also think the way you are doing it now is a bit farfetched.

#12

My biggest user case is for adding in fields with certain formatters into the stream. So for example I use video filter field module which allows a user to add a URL for youtube, vimeo etc. When this pops up in the stream I want the video to be available but with a specific size. The same goes for an image attached to a node, I want to attach the image in the stream but using a specific formatter such as shadowbox. Both of these can be done through custom php in rules but its complicated (especially the video) and I dont have the skills to build a custom plugin. Instead I added a ds custom field to the template for "user added a video" and embed a view directly in that field (which works well I must add).

Having views bring in the extra fields into the stream brings in all the great values of arguments, relations, field formatters etc etc. It actually also means that adding a new stream does not require adding further code as it can all be done through filters and so on.

#13

Category:bug report» support request

This is a perfect use case :)

Well, the way I do this, is adding a custom extra field (hook_field_extra_fields) to the heartbeat bundles (Heartbeat templates) myself. This is pretty easy but the real magic is in the view modes and certainly with Display Suite enabled.
The trick is to use the heartbeat_activity>Node ID and perform a node_view(node_load($nid), $your_custom_view_mode) output.

This means you can create a custom view mode "stream display" or something. You always render the nid's node through that view mode in your extra field.
Advantages:
- You have a field UI to arrange that custom extra field in your messages.
- You have the node display UI to arrange how the content within that extra field is shown.

Does this help you?

#14

Category:support request» bug report

Yes, this seems similar to my views way but at least leaves views out of the picture. Im still a relative n00b at php and drupal and more of a gui kind of guy, so please excuse me on the below implementation (i.e. please suggest corrections!). It works but maybe there are some things I have not taken into account:

  1. Add a custom view mode through Display Suite > View Modes and name it "stream display". Choose which entities to apply it to (in my case node).
  2. Go to manage display for the entity which you wish to display in the stream and check the checkbox "stream display" then save.
  3. Customise the stream display with whatever fields you wish to use.
  4. Go to the heartbeat template that you want this display to be attached to and add a display suite custom code field.
  5. Add the following using display suite code text format:
    <?php
    $nid
    = $entity->nid;
    $node = node_load($nid);
    $display = 'stream_display';
    $content = node_view($node, $display);
    print
    render($content);
    ?>

#15

Status:needs review» fixed

Looks good. It should work (extra load of the node ofcourse, so think about performance ...).
So you can close this issue. Maybe change the title into something other people can be helped by implementing your use case ;)

#16

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.