Wondering if anyone has given thoughts to CCK support for Activity Stream items.

Use case:
-I want to store information beyond body text and title (e.g. Edit dates from FlickR)

CommentFileSizeAuthor
#5 cck_fix.patch900 bytesseanb

Comments

xurizaemon’s picture

Title: CCK » Ability to store additional information in custom (CCK) fields

What you want is the capacity to record additional data about imported items in CCK fields? That's a good idea, Jorge.

(If I'm wrong, please correct the issue title to be more descriptive.)

GMercey’s picture

It can be a good idea to store image link attach to an item, like a Greader item. How can we get the link and store it in a cck field?

jorge’s picture

xurizaemon: correct. Thanks for renaming.
GMercey: Exactly, there are sometimes more complex pieces of information in these streams.

I'm open to sponsor this addition to the API, anyone able to do it soon?

winstonford’s picture

Here's an example of what I believe to be the goal of this thread, or at least similar to it:

1. Enable the Aggregator module found here /admin/build/modules under 'Core - optional'.

2. Create a feed at /admin/content/aggregator/add/feed using the feed below:
http://feeds.pandora.com/feeds/people/john/recentactivity.xml

2. View the results at /aggregator

You should see the feed, with each item showing all the elements exactly as the original raw feed presents them, such as images, icons, links, etc.

I understand that Aggregator does not then go and create a node for each feed item, which I actually prefer, and so these extra elements in each feed item are not cck fields.

I am just wanting the imported feed at /user/1/activitystream, or the activitystream block, to look like the one at /aggregator

Is this example, at least visually, similar to the goal of this thread?

seanb’s picture

Status: Active » Needs review
StatusFileSize
new900 bytes

For a client I needed to store the link and image of a Facebook status with the activity stream node. I wanted to store this in CCK because storing the data in the body field of the node was not flexible enough. To make this possible I created a patch for the activity stream module. It basically merges the data returned by hook_streamapi with the node object. This way any extra module can return the CCK fields.

I hopes this helpes someone. I did some tests and it didn't break any default functionality, so I think this could be commited to the module.

Let me know if it helps!

seanb’s picture

Here's an example of how I added the CCK data:

function activitystream_facebook_streamapi($user) {

  // This user doesn't have a Facebook ID entered
  if (!$user->userid) {
    return;
  }

  // Use the Facebook GraphAPI to pull in the user's status updates
  $updates = json_decode(file_get_contents('https://graph.facebook.com/'.$user->userid.'/feed'));
  $items = array();
  if (is_array($updates->data)) {
    foreach ($updates->data as $item) {
      $ids = explode('_',$item->id);
      $activity['link'] = html_entity_decode('http://www.facebook.com/permalink.php?story_fbid='.$ids[1].'&id='.$ids[0]);
      $activity['title'] = html_entity_decode($item->message);
      $activity['body'] = $item->message;
      $activity['timestamp'] = strtotime($item->created_time);
      $activity['guid'] = md5('http://www.facebook.com/permalink.php?story_fbid='.$ids[1].'&id='.$ids[0]);
      $activity['id'] = md5($ids[1]);
      // Check for extra CCK fields
      if (module_exists('content')) {
        
        // Get content type CCK field
        $type = content_types('activitystream');
        $fields = $type['fields'];
        
        // Add link
        if(!empty($item->link) && isset($fields['field_link']) && $fields['field_link']['type'] == 'link'){
          $activity['field_link'] = array();
          $activity['field_link'][0]['url'] = $item->link;
          if(!empty($item->name)) $activity['field_link'][0]['title'] = $item->name;
        }
                
      }
      $items[] = $activity;
    }
  }
   
  return $items;
}
morbus iff’s picture

Status: Needs review » Fixed

This is possible in 7.x-3.x - the Activity Stream item nodes are fully fielded, and a module could add new fields to the content type, then listen on hook_node_presave() to apply the extra data to those fields. Themes receive the whole $node object and would be able to use that data in the stream if they'd like.

Status: Fixed » Closed (fixed)

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