I have a view setup to disply a stream of activity which is just hideous, there is a field for a users profile avatar, 2 fields for flags, the message field, activity comments field, the delete field, node fields (such as images/videos etc) and all require quite a few relationships so the query generated will just not scale at all!
I figured the best way around this is to insert all of those fields into the activity message and therefore only 1 field is being queried by the view.
The avatar and node fields I can get around by adding tokens so thats fine. The problem is adding the flags and comment form which need to be dynamically generated.
I attempted to do the following, generate the dynamic content after the message has been created and add the resulting html to the message kinda like:
function my_modulel_activity_message_recorded($record, $context){
$flaglike = flag_create_link('activity_flag', $record->aid);
$flagdislike = flag_create_link('activity_dislike', $record->aid);
$comment = drupal_get_form('activity_comments_form', $record->aid, 2, 'ASC');
$message = array();
$message[] = "<div class='inner-message'>/*originalmessage*/</div><div class='views-field-ops'>".$flaglike;
$message[] = "</div><div class='views-field-ops-1'>".$flagdislike;
$message[] = "</div><div class='views-field-comment'>".$comment."</div>";
$message[] = (int)$record->aid;
$result = db_query("update {activity_messages} m inner join {activity_targets} t on m.amid = t.amid SET m.message = '%s%s%s' where t.aid = %d",$message);
}
which pretty much failed. What I need is the flags and comment form to be initialized when the view is being rendered. So what I was thinking is if you could create a template message such as:
echo flag_create_link('activity_flag', [aid]);[activity-node-creator-link] created the [type]: [activity-node-link] echo drupal_get_form('activity_comments_form', [aid], 2, 'ASC');
and then substitude [aid] in _activity_message_recorded().
Is this a crazy idea? Or is there a more sensible approach to this?
Greatly appreciated!
Closed: outdated
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.