I have user galleries on my system, and it would be nice for the images that are added to FB status, to be able to be added to lets say "Status Gallery" for example.. any way to do this?

Comments

publicmind’s picture

which module you are using for the galleries, I have been wanting to integrate 'photo' plugin with a gallery module but hadn't yet found a good enough gallery (photo albums) module.

gateway69’s picture

well, I played with many galleries but ultimately I just found using something similar to views gallery (module) which is just a combination of a gallery and image with some nice views.. I think it gives you the ultimate flexibility.

May I make a suggestion:

With the ability of cck node reference, when I upload images from my image content type, I select the gallery as a node reference, hence telling the image to be associated with this gallery, So ideally it would be nice to select what content type this image should be associated with and what gallery by the node reference..

Im not sure how to do that on my end, I was thinking of finding the code you had where you create the image, changing that to nodesave() for my image content type, with a default gallery value hardcoded. I think this would allow me to save the image to my image type, define a gallery I want it to go in "Default" , "Status Gallery" and then when clicking on the actual image from the FB status it loads the node instead of just loading the image.

also be nice to have a image cache preset you could set for both a link image and a photo image..??

ST

publicmind’s picture

I will have to look into the module a little to comment about its ability to become the FBSMP gallery module.

You can already set imagecache preset on a photo image. It is not possible to set presets on link image as the image is never stored on your local server, so you can't modify the image.

gateway69’s picture

Where are you saving the images to so far?

Could I go in and where the image save code is change it to nodsave with the current uid and in nodesave I'll hardcore the gallery node id..

I haven't looked at the code yet but have some time this week to.

gateway69’s picture

So over lunch im finally getting a chance to look into this .. here is what I have so far in the time I have had..

I added Gallery settings to the admin section

   /// get a list of nodes and display them in a drop down
  $list = array_map('check_plain', node_get_types('names'));
  $form['gallery']['associated_node'] = array(
	'#type' => 'select',
	'#title' => t('Associated Image Node'),
	'#options' => $list,
	'#default_value' => $prev_settings['associated_node'],
	'#description' => t('Select which node content type you want to associate an image with.'),
  );

  $form['gallery']['gallery_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Default Gallery name'),
    '#default_value' => $prev_settings['gallery_name'],
    '#size' => 15,
    '#maxlength' => 10,
    '#description' => t('The default gallery ID to save Status images to.. Requires a Gallery Content type check Views gallery Module'),
  );

and also added in fbsmp_photo_fbsmp_admin_settings_form_submit

  $settings['associated_node'] = $form_values['associated_node'];
  $settings['gallery_name'] = $form_values['gallery_name'];

next looking at your fsmp table, I was thinking of adding node id, and default gallery node id.. NOTE people would need to set up a gallery and image content type, very easy to do, and have the images node reference the galleries, plenty of tutorials and even views gallery module makes this easy to set up.

the idea now is to pass in the content type that the images should be associated with , this is in the pull down of gallery settings.. in my case "image" , then input the gallery field id they want (prob should make this nicer) I know I have a default status gallery with id "5"

what im looking at now is the file.inc which to be honest I never dealt with to much and looking for a good place to add code that would do the following:

Once the image saves, use node_save http://api.drupal.org/api/function/node_save/6 to create a new node in drupal with

content type = 'image'
uid = user id
gallery id = '5'

the rest can be auto filled in or the description could be the status update.

so something like this

			$fb_image_node = new stdClass();
			$fb_image_node->body = '';
			$fb_image_node->type = 'image';   // Your specified content type
			$fb_image_node->created = $time;
			$fb_image_node->changed = $time;
			$fb_image_node->status = 1;
			$fb_image_node->promote = 0;
			$fb_image_node->sticky = 0;
			$fb_image_node->format = 1;       // Filtered HTML
			$fb_image_node->uid = $user->uid; // UID of content owner
			$fb_image_node->field_fb_uid[0]['value'] = $fb_uid;
			$fb_image_node->field_gallery_nid[0]['value'] = $gallery_nid; // the gallery you want all images to be associated with for the user
            $fb_image_node->field_image_fid[0]['value'] = $fib;  // associated fib for which file was saved in the files table
            // of course you could add in more fields, title, description 

			node_save($fb_image_node);

of course im not sure if this is the best way to build a node, but it would then associate the FB image that was added by the user, to content type = image , with gallery id 5, and be an actual node that users could view, and do other things with if image content type had like comments, ratings etc..

thoughts on where to help me with this part?

ST

R-Man’s picture

Is it possible to place the code ( http://drupal.org/node/40087 ) in the user profile to display photos uploaded from Micropublisher? Maybe need some editing?

gateway69’s picture

Yea the idea is to really add additional functionality to micropublisher , to allow admins to select an image content type, and a default gallery that the images can be associated with.

From looking at the code i only see that the fib is being stored and isnt associated with a real node, ideally from what I understand how drupal works, when uploading an image, a fib is returned, then the node is saved with the rest of the data and the fib..

gateway69’s picture

Ok, hacking around, I have it sort of working, need to address a few things, and also make sure the node is deleted when you remove the image.

pribeh’s picture

This seems really interesting, gateway69. I think might be the best approach for drupal 6. The two websites that I need to use fbsmp photos for need them to function like galleries on Facebook or flick do. Each image needs to be displayed on it's own page with a status/description and for a block (say comprises of a view) with the previous and next photos to be displayed, say, to the right or left of it. It would appear that the node approach for this would be best. Thanks a lot for contributing this. I will test out your implementation soon.

gateway69’s picture

hold off, i need to spend still some cycles on it and its still a bit hacky, but I should have something soon

publicmind’s picture

I am liking the way it is going. FBSMP integration with a gallery would be really awesome. If you can just create a module, which integrates with FBSMP and provides gallery support to it, then it would be awesome for other users as well.

FBSMP provides a wonderful API (unfortunately, little undocumented) which can help you do this, without touching any of the existent code and will make your life easier with upgrades in future.

hook_fbsmp_save($status) is fired when your status is saved. You can implement it to create and associate the node at this point with the photo. fid of the image will be $status->attachment->data['fid']

hook_fbsmp_delete($status) when the status is about to be deleted. You can delete your nodes at this point.

Let me know if you need any help with this.

gateway69’s picture

Ok, ill work on it this weekend, its working for the most part except for the views part.. when you view a status with an image, when clicking on it i want to go to the node..

Ill see about putting it into a separate module as well.

thanks

publicmind’s picture

That sounds great.

hook_fbsmp_render_attachment_alter(&$themed_attachment, $attachment);

I just added this hook which you can implement and make changes to the $themed_attachment HTML string which would be finally displayed in the status stream. You should do something like this:

function mymodule_fbsmp_render_attachment_alter(&$themed_attachment, $attachment) {
  if ($attachment->type == 'photo') {
     //encapsulate the $themed_attachment inside the link to node here.
    $themed_attachment = l($themed_attachment, 'node/123', array('html' => TRUE));
  }
}
gateway69’s picture

Ok a bit of an update right now.. I have separated this into a new module and have most of the functionality except delete working.

I'm able in the admin to select a image node type (currently node_save function is hardcoded to my image cck files : how do I fix this).

When node save is triggered in fbsmp_node_fbsmp_save function...

A new drupal node is created, with some default settings, uid who created the node, the content type you wanted to save it with, and some extra fields that im going to remove when I release the module.

I did have to add an extra row to fbsmp called nid, this is the new node thats its associated with in drupal, not doing this would cause a lot of head aches on how to the sid in fbsmp was associated with what node.. (alternative solution?)

Lastly I implemented the theme to load up the node when the image is clicked on, how ever I need to revert to the old method of just displaying the images if users had this system in place already before using this module (suggestions) ?

and lastly what I'm stuck on is the delete function, since $status doesnt pass along the nid from the fbsmp table Ill need to probably grab the sid from $status->sid, query the db with the sid to get the nid , then do node delete.. at least thats what im thinking.

the does isnt cleaned up but here is the main module part , which ill work on more, suggestions, optimazations are welcome.

<?php
// ; $Id$ - Facebook-style Micropublisher Image node - Gateway69

/**
 * Implementation of hook_form_alter().
 *
 * The function is named modulename_form_alter.
 */
function fbsmp_node_form_alter(&$form, $form_state, $form_id) {
  // Add Gallery settings to Admin settings for photo
  if ($form_id == 'fbsmp_admin_plugin_form') {	  
	  
	  $prev_settings = fbsmp_load_plugin_settings('photo');  
	  // debug
	  dsm($form);

	   /// get a list of nodes and display them in a drop down
	  $list = array_map('check_plain', node_get_types('names'));
	  
	  $form['general']['associated_node'] = array(
		'#type' => 'select',
		'#title' => t('Associated Image Node'),
		'#options' => $list,
		'#default_value' => $prev_settings['associated_node'],
		'#description' => t('Select which node content type you want to associate an image with.'),
		'#weight' => -1,
	  );
   // is this required ???
   $settings['associated_node'] .= $form_values['associated_node'];  
  }

}

/**
 * Implementation of hook_fbsmp_save().
 *
 * The function is named fbsmp_node_fbsmp_save.
 */
function fbsmp_node_fbsmp_save($status){

  if ($status->attachment->type == 'photo') {
   	
	  // grab the settings from the photo plug, parse out what the user set for gallery and node to save as
	  $gallery_settings = fbsmp_load_plugin_settings('photo');
	  $gallery = $gallery_settings['gallery_name'];
	  $node_type = $gallery_settings['associated_node'];
	  $file_id = $status->attachment->data['fid'];
	  $uid = $status->uid;
	  
	  // build a new object to save to the node thats related to your image.
	  $file_new = new stdClass();
	  $file_new ->body = '';	  
	  $file_new ->type = $node_type;   // Your specified content type
	  $file_new ->created = $time;
	  $file_new ->changed = $time;
	  $file_new ->status = 1;
	  $file_new ->promote = 0;
	  $file_new ->sticky = 0;
	  $file_new ->format = 1;       // Filtered HTML
	  $file_new ->uid = $uid; // UID of content owner
	  $file_new ->field_image[0]['list'] = 1;  // is this required? 
	  $file_new ->field_image[0]['fid'] = $file_id;  // associated fib for which file was saved in the files table
	  // of course you could add in more fields, title, description 
	  
	  node_save($file_new);	
	    
	  $nid = $file_new->nid;
	  $sid = $status->sid;

	  // Save the node id created by node save to the fbsmp table
	  // Could be a better way to do this, but for now required additional field nid in table fbsmp
	  fbsmp_node_nid_save($nid,$sid);
	  
  }
 
}

/**
 * Implementation node saving to fbsmp table
 *
 * The function is named fbsmp_node_nid_save.
 */
function fbsmp_node_nid_save($nid,$sid){

 // a cleaner way?
 //drupal_write_record('fbsmp', $nid,'nid');
 $result = db_query("UPDATE fbsmp SET nid = $nid WHERE sid = $sid");
}

function fbsmp_node_nid_get($sid){
	
  $result = db_query("SELECT nid FROM {fbsmp} WHERE sid = %d", $sid);
  
  $records = array();
  while ($record = db_fetch_object($result)) {
	$records[] = $record;
  }
  
  $node_id = $records[0]->nid;
  return $node_id;
	
}

/**
 * Implementation of hook_fbsmp_delete().
 *
 * The function is named fbsmp_node_fbsmp_delete.
 */
function fbsmp_node_fbsmp_delete($status){
  
  if ($status->attachment->type == 'photo') {	
  // get node id somehow ??
  
  }
	
}

/**
 * Implementation of hook_fbsmp_render_attachment_alter().
 *
 * The function is named fbsmp_node_fbsmp_render_attachment_alter.
 */

function fbsmp_node_fbsmp_render_attachment_alter(&$themed_attachment, $attachment) {
  if ($attachment->type == 'photo') {
	  
	  $sid = $attachment->sid;
      $node_id = fbsmp_node_nid_get($sid);
	  
	  // safe guard if previous attachments where not used prior to this system
	  if($node_id == 0) {
	  
	  // need to fix this, not sure how to display the proper link to the image	  
	  return '<span class="fbss_attachment" id="steve">'. $themed_attachment . '</span>';
	  
	  } else {
     //encapsulate the $themed_attachment inside the link to node here.
    $themed_attachment = l($themed_attachment, 'node/'.$node_id.'', array('html' => TRUE));
	  }
  }
}
publicmind’s picture

Isn't this (http://api.drupal.org/api/function/node_get_types/6) will do? What do you actually need? You can get all the node types using this function and then filter out those which are not applicable.

Instead of adding a new column to the fbsmp table, it would be much more better and maintainable if we create a new table which would store this (sid=>nid=>gallery) mapping information. I am not sure which information is required to be stored. Do we need to store both the nid and gallery id, OR gallery id is stored with the node? This way your module can be easily installed and uninstalled without the hassle of changing columns in the main fbsmp table :)

It would also solve your problems with delete. You have the sid, you query this new table for nid, and delete the node.

Your theme function can be something like this:

function fbsmp_node_fbsmp_render_attachment_alter(&$themed_attachment, $attachment) {
  if ($attachment->type == 'photo') {
 
  $sid = $attachment->sid;
  $node_id = //Load it from the new table;

  // safe guard if previous attachments where not used prior to this system
     if($node_id) {
       $themed_attachment = l($themed_attachment, 'node/'.$node_id.'', array('html' => TRUE));
     }
  }
}

FBSS will automatically append the <span> tag with relevant information, so you do not need to do anything.

Cheers,

gateway69’s picture

Ok, im almost done, just a few more things to figure out, (sorry new to module dev, but long time php guy)

1. I moved fbsmp_node into its own table, with .install file
2. Updated the functions to reference this table
3. fixed the delete function.

So todo, and not sure how to handle this since its druplish type stuff ..

In my hook form alter, im adding a field to your admin area where the user can select which one of their nodes is set up for image type

I cant seem to have the settings save along with yours, you can see mine is listed at the top
http://grab.by/6OGf if i save that page, it doesnt get saved with your settings I tried to add this to the form alter function

$settings['associated_node'] .= $form_values['associated_node']; 

which is the setting for what node the admin checked..

thoughts?

Once I can get that done, I can clean up the code for a alpha release.. note this only saves to the image node, you cannot define a gallery to put them in yet (i have my example hardcoded)

Also how can i adjust the weight of my form alter in yours.. to move it down under image cache settings

questions to anyone:

right now you select your image node in admin, by doing this you will associated fbsmp photos to that node, clicking on the image brings you to that node..

How would you like to associate this to a gallery?

my setup is
gallery content type
image content type
----> gallery list
type = node reference gallery

so when adding photos i get a drop down list of galleries to put them in.

with fbsmp, this is a quick photo status post.. do we allow admins to define a gallery name to use "status gallery" .. still thinking that though..

also I think in the photo widget we should add a title, so you can add a title to your image which would then get stored to the node

pribeh’s picture

@gateway69 In response to your question about 'which gallery' to associate with in #16:

Your image gallery setup is interesting but can't we just use tags to organize image galleries?

All we need is for the image node page to be displayed with corresponding image and status text. Combined with the right user/node argument(s) we can display the gallery thumbnails inside a Views block. If we want to allow for further organization of photos into specific galleries we can allow for (free) tagging of the nodes after the status and image has been posted and the user has navigated to the image node page (there are numerous ways to offer users intuitive ways to do this). We could then provide Views of user image galleries organized by tags. Again, this is sort of like how Facebook does it.

Also gateway69, FBSS does provide tagging (with hashtags): if we could figure out a way for those tags to be absorbed (imported) into the image node then this would be uber powerful and dead simple for the user.

Am I making sense?

gateway69’s picture

I can add the ability for your comment to be added to the image node.. The question is should this be the title, or the description... In facebook they name it a caption that goes along with your photo and you really dont have a choice as to what gallery it goes in by default, only after you edit that image can you potentially move it.

for my purposes when a user signs up to my site by default a mobile photo gallery, and default gallery is created. When users upload via mobile phone it goes into mobile gallery.

If you also suggest using taxonomy adding tags that could be done, but the prob is that each person will need to add or enable taxonmoy on their image node... I cannot control what the user does as far as what he does to make his image node, ideally i hope they have title, description, image, at the very minimum.

For the first alpha release Ill just allow the admin to select what image node is to be used. When someone posts an image via fbsmp create that image node and associate it with that in the view.

I need to think about other things on how to proceed and prob good to move it to its own section very soon.

pribeh’s picture

@18 I think we should consider using the status as the title like Facebook does. Facebook organizes photos according to what people are tagged. Obviously though, use cases can stretch well beyond that calling for either taxonomy or tagging to be an option.

Based on user case scenarios I've encountered I don't think most users are going to go back into the image node and add a description, etc. They may, if they're a photographer, go back into the image node page and edit it. So using the status as title is best since they're likely not to want to change the title of the image node. Photos are not like blog posts I've realized as most users (except if they're photographers and picky) don't want to add titles or descriptions. Facebook, Picassa, along with other photo sharing sites, by and large have made them lazy :) and, hence, they just want to post the photo.

If you're concerned with how few people may go back into the node and edit it so as to tag, or choose a gallery for, it perhaps you could consider using an exposed (editable) field on the image node page for users with the right permissions. That way, it shows immediately to users who visit the image node page that they can add tags (with an exposed) input field or choose a gallery (via a drop-down).

Let me know if my input is valuable.

gateway69’s picture

Pribeh, Ill consider doing it this way, I need to solve my 2 issues first, and this week is quite busy here for me :(

publicmind’s picture

@#16

I think you should have a separate settings page for your module instead of cluttering the photo plugin page. I ask you this because it will give your module the independence to work with several FBSMP plugins. In future, we might want galleries for videos as well or say documents. What do you say?

To which gallery the image should be associated would bring how flexible you want your module to be. To start with, as you said, there should be at least a default gallery selection available to the admins. You can afterward incorporate very useful comments from pribeh in #17.

Also, I do not think we should be having a title field for photos. "Sharing should be easy and fun", and asking users to enter the title would be moving them away from sharing stuff. That is why you would see, that only slideshare document plugin has a required 'title' field because I think 'status' in that case can never become a 'title'.

gateway69’s picture

thanks everyone, Ill look at this over the weekend, I need to solve how do i find what field is the fid for the image content type the user creates..

When an admin creates an image content type I have no control over what they will name the image field, for example mine cck type is

Photo --- field_images -- type file -- widget imagefield..

the part that I need to figure out is what the admin names the field, because im sure everyone will create a node with a differnt field.. aka.. field_my_photos..

the reason I need to find this field is when I do a node_save i need to make sure im sending the returned fid to the right field for the node.. right now in my code its hardcoded to use mine...

drupal provides a content_types($node_type); to a huge array of all the fields, values of a content type.. in my case 'photo' , I need to search though the array, to find module => filefield or module=> imagefield then find out the actual field name thats used, unless their is a better way.

thoughts?

publicmind: ill work on separating the settings, im assuming I should create a new admin setting widget that can be used for photos, videos etc?

I also had a thought to parse hash tags, and if in the admin taxonomy was enabled for this node, put the hash tags in the taxonomy so people can do all sorts of things with views and tags.. ?

publicmind’s picture

@gateway69

With separate settings I mean you create a separate module with separate settings page instead of writing a plugin (as it is not a plugin). I would prefer it to be called Facebook-style Micopublisher Gallery.

You should look into the code of the module FeedAPI ImageGrabber as it would help you solve the issue with the content field. The module does exactly what you are trying to do. It asks user to select an imagefield and content type into which it stores the downloaded image from other sites.

Regards,

gateway69’s picture

@publicmind

Thanks...

I actually have a separate module, and its own admin page.. everything is working, ill look into feedAPI next.

Ill also change the name..

question, do u want it to have a completely own admin section, or a tab in your area.. I have it in its own page now..

I should have this wrapped up as a alpha this weekend, its been a super busy week :(

gateway69’s picture

So I think im gonna wrap up an alpha... The first release will just let you from the admin select the node that has your imagefield, then you need to enter the field name that is related to your image.. aka from your cck content type example "field_my_photos"

once saved, when you add an image via the FBsmp status page, you can click on the image which then goes to your image node, if you delete your status your node is also deleted.

other features will come in time.

pribeh’s picture

Amazing. I look forward to testing gateway69.

publicmind’s picture

Can you upload the module to this issue queue before creating a project page, so we can review or even make modifications? Also, follow the coding guidelines (http://drupal.org/coding-standards) and format using the coder module (http://dgo.to/coder) .

Thanks,

gateway69’s picture

StatusFileSize
new3.4 KB

yep.. let me clean up some of the code, I haven't renamed it yet..

attached is a rar of the module name is currently fbsmp_node since it attaches an image from fbsmp to a node.. but the name can be changed I really dont care.

First create a content type with just a title, and cck imagefield (note the name of your imagefield you create in the cck) for mine i just did file_my_image

save your content type..

enable the plugin, go to the admin section, from the pull down select your content type you just created and in the text box enter your field name thats your imagefield for the cck field. (I want to figure out how if you select a node , to list the fields in a check box format or find and display to the user the one imagefield) no idea how to do this.

once your settings are saved..

when you do a update with a pic, after its uploading, if u click on the pic it should go to the node..

gateway69’s picture

any feedback?

publicmind’s picture

will have a look at it tomorrow!

pribeh’s picture

Likewise.

pribeh’s picture

Hi Guys,

So gateway69's fbsmp_node module from #28 seems to work without a hitch on my end. I'm testing it with a dev build of londonfuse and it works effortlessly. I am going to let a few beta testers experiment to try and break it though.

I must say that this approach might be beneficial to the video plugin as well.

Best,

Thomas

gateway69’s picture

Yea, ideally you could expand this to work with videos as well, in fact anything that generates some sort of content could be turned into a node, I could use a bit of help though making it idiot proof and for my own purposes im going to be adding in linking to a gallery, and other cck types i need. I might add taxonomy to it as well , aka the admin can set default taxonomy terms that then can be used in views or other ways

pribeh’s picture

#33 That's great.

Are you still considering populating the title of the node with the status? That still makes most sense to me.

publicmind’s picture

Initial comments after looking at the code:

  • You do not need to make dependency on ctools or facebook_status (in .info), as you have nothing to with it. Just make a single dependency on fbsmp, and it will automatically make your module dependent on all the modules fbsmp is dependent upon. Also, make a dependency upon the gallery module you will be using. BTW, which is it?
  • You do not need to use drupal_load() in your install and uninstall functions (in .install file).
  • In fbsmp_node_admin, you would want to either do away with the 'general' in your $form or add a fieldset for it.
  • You should do the following to remove the textfield input from the user.
    • let the user select a node type from the node dropdown
    • via AHAH, you update the next option which will be the dropdown of the (only) imagefields associated with the selected node. Look for "AHAH + Drupal" tutorial.
      To scan the list of CCK fields for the imagefields of the selected node:
      function mymodule_scan_fields($content_type, $widget_type = 'imagefield_widget') {
        $info = content_types($content_type);
        $fields = array();
        if (isset($info['fields']) && count($info['fields'])) {
          foreach ($info['fields'] as $field_name => $field) {
            if (isset($field['widget']['type']) && $field['widget']['type'] == $widget_type) {
              $name = isset($field['widget']['label']) ? $field['widget']['label'] : $field_name;
              $fields[$field_name] = $name;
            }
          }
        }
      
        //$fields is populated with all the imagefields (if parameter 2 is not passed), associated with the $content_type
        return $fields;
      }
      
  • Why is the gallery hard coded? Shouldn't it be also an option on the settings page?

I would advice to keep the name as "Facebook-style Micropublisher Gallery" abbreviated as fbsmp_gallery. It will let us add video, etc support to it in the future without nomenclature issues. You should also try to format the "descriptions" of the fields while keeping in mind that this might not be 'image' specific.

I will probably get some time this weekend to try out the module, will let you know more.

Thanks,

gateway69’s picture

Thanks for the feedback, I do have to say this is my first attempt at a full blown public module to release to people and im still learning the in's/outs from the drupal api, so thanks again for the comments.

The hard coded value for gallery was just my tests, I haven't gotten to linking anything to a gallery the first steps where to just get it to link to the image node and work from their.

Unfortunaly with Drupal their are many ways to make a image gallery I followed this method http://www.lullabot.com/articles/photo-galleries-views-attach a year or so ago, which turned into a module called views_gallery which then is evolving into a more proper module but requires a lot of additional modules I dont need personally.

At the very basic level you an can easily create 2 content types

* Gallery Content type
** Title
** Description

* Image Content Type
** Gallery (node reference)
** Image (image file field)

this is the basics, of course then you need to create views to generate a gallery view, image view etc... which isnt to hard , you can go as crazy as you want , for those that dont know how views gallery is a good solution, I prefer the first version that doesn't require Features module.

For me every time a user creates a new account in drupal, I have a rule that generates a "Status Gallery" for them linked to their NID. I can see in the future that the admin could define a default gallery name that the images go into, or giving more flexibly using taxonomy to allow the admins to use those terms to build nice custom views or themes.

Also galleries offer other issues, right now the way things are set up, its based upon global galleries, so a user creates a gallery, and anyone can add to it, I have created custom filters to only show a gallery that the user has created and only allow them to add to this. (sorry getting side tracked)

So as for the best solution to tie this to a gallery im not sure, seems like taxonomy might be a way and im up for suggestions. The main idea of course is just to get the functionality to link status items to nodes that are defined, which is the first piece of the puzzle. So you can see their are a lot of ways to make a gallery in drupal, which goes beyond the scope of this plugin, trying to figure out a nice solution is a bit harder.

@pribeh

Yea, I could make an option in the admin that you could enable status updates to be node title names

@all - I have very limited time but will tackle some of these changes above this week but most likely the weekend

gateway69’s picture

Sorry guys, I have been super crazy busy, I started to look at this again tonight and AHAH, however I'm not quite getting it and need to do a few test examples, Im curious if anyone wants to help me finish this and add in the ability save video nodes as well.. I would like to put this to rest I just haven't had any time :(

just_fixed_it’s picture

Hi guys.

I've been using my own 'stuff' similar to FBSS & FBSSC that I bashed together a good while ago. I now need to add links & images, and before I got stuck in I came across this module. It looks very interesting.

What I was thinking of doing was an upload image/nodereference_explorer kind of widget. Is this where you're going? Or more linking in with existing gallery modules?

If I already have a widget and wanted to integrate it, any suggestions?

I'm a little confused ... my usual state of mind ...

gateway69’s picture

With FBSMP you get what was missing in the facebook status which allows you to add image, video, link or other to a post. What was initially missing was that when you posted a photo that it wasn't linked to an actual node in drupal, it was more or less just showing you an image on the server.

For what I wanted to do at the first layer is just in the admin layer select my image content type with image field cck , and then when posting via the smp assign it to an actual node, now that its a node well you can do what you want with it, custom views, taxonomy, sorting etc..

thats the first step.. the gallery part I think is up to the user since I use a very of views gallery (not their latest version) and I feel comfortable enough with using this light weight one than others.. but the prob is others might use other methods.. so thats sort the state.. I need to dig into some of the suggestions above to make this a full releasable module but have lack of time and still cant wrap my head around AHAH

just_fixed_it’s picture

Thanks for the info. Much appreciated.

So as I understand it ... ... once the admin has set the node type, when the user clicks the image icon under the status text box, the filename/browse widget appears, and the user uploads a photo. In code this creates a new node of the given type and saves it. Can the user also decide to reuse an already existing node in a status update rather than upload a new image?

Currently I have a widget which works on a cck field type. You add a field of that type to a node and use the associated widget. When editing the user can upload a new photo from their computer or enter the name of an existing image in an autocomplete box (it's an adapted uberimage type with image cropping on multiple image presets). It works nicely. All the gallery stuff is done using views.

What would be great is if I can stop using my custom status stuff, replace it with FBSS+bits, and ,importantly, use my existing cck widget stuff. Do you think this would work as a plugin for FBSM?

publicmind’s picture

@gateway69

I understand the time constrain (which I am going through as well ;), but I think we are much closer to the final module, so lets crack it. Here are the few nice tutorials:

http://drupalsn.com/learn-drupal/drupal-tutorials/getting-going-ahah-and...
http://drupal.org/node/131057

Let me know if you need more help.

Just a thought, we can also abstract out the gallery support so that you later can add support for more gallery modules (requests for which will pour in once this module is in action).

Regards,

pribeh’s picture

Hey gateway69, this module works really well. I'd say the only big remaining issue is choosing what to populate the title and description with. The title still remains unpopulated after being posted. I'd say by default we should have the actual filename of the image populate the title of the node and then have the status populate the description (body) field.

Let me know where you're at because I'd love to integrate this into a site I'm pushing live very soon. And thanks again for your work on this.

gateway69’s picture

Pribeh,

It wouldn't be to hard to hack in the name for the title.. I unfortunally have been swamped here at work we have a huge deadline before the xmas holiday for this video game we are working on. I have a nice holiday break where I plan on doing some work on my sites and a bit on this module.

I loooked more into AHAH, well not as much as I had planned still not clear how it works, ill have to create a test module and play with it a bit.

Pribech, if you dont mind how are you planning on using this, also are you styling your status updates like FB.. my idea for one of my sites is to have a similar look/feel as the facebook status feed with images, videos and links.. I guess just need some good styling.

pribeh’s picture

StatusFileSize
new43.94 KB

@gateway69, I'll definitely try to see what I can do to populate the title and description. I'll post my results.

As far as styling is concerned I'm using both Facebook (for the statuses) and Flickr (for the photo pages) as prototypes. I've attached an example of how it looks on the new LondonFuse site I'm working on. Oh, I was going to add, let me know what you need more specific help with and I can definitely give you some pointers.

gateway69’s picture

@pribeh, finally an example of using the FB status module and seeing some good css around it.. is this something you coded?

anyhow I know off topic..

It would be nice if fb smp when adding in an image, had an *optional* title field, I could then pull that and put that into the node..
Otherwise your limited to parsing some text inside the status update..

pribeh’s picture

ya, I figure the best option is to probably use the filename since it will always definitely exist, whereas the status is not a definite variable. Thus, the status might make a good description/body candidate.

As for the screen, ya, that's what I'm currently skinning. I use FBSS/FBSMP in tandem with the Activity module. I use just the publisher template, along with Views' theming system to style all sorts of content in one single feed, aka, like on Facebook.

gateway69’s picture

file name should be easy to do.. i can look at this during lunch.

would you mind sharing your aka facebook style stuff? I'm wanting to do something similar on one of m social sites im building.?

pribeh’s picture

Do you mean the CSS for the Activity Templates? Since I'm using the Activity module I use some custom html with tokens to build the look of the status in the View and then apply the CSS aloft this. If you want I can provide both the html/token layout and CSS (?).

macuhail’s picture

Just wanted to check on the status of this module. We need something like this for a new site.

Thanks!

pribeh’s picture

Hi macuhail. There is a version of the module which does allow for the assignment of the node title from the filename which works fine. I can post it here later if you like since it looks like a project page for this might not be in the works - unless gateway69 has plans I'm not aware of.

Best,

Thomas

gateway69’s picture

dont go sharing the code :) j/k

please insert $20 ..

ill make some effort to work on the module next weekend, but yea please share, help and maybe we can all put one together

macuhail’s picture

Pribeh, it would be great if you would post the module.

Gateway69, we would be glad to help out with a donation. Unfortunately we don't have the expertise to help with the coding. We will be happy to test and report any issues however.

macuhail’s picture

@pribeh,

Just wanted to check back and see if you could post the code.

Thank you.

pribeh’s picture

Sorry for the delay macuhail. I wanted to make sure it was ok with Gateway69 - and I guess it is. I will post it as soon as I get to my terminal in the morning.

macuhail’s picture

Sounds good pribeh. That will be a big help.

pribeh’s picture

StatusFileSize
new4.08 KB

Here it is.

gateway69’s picture

just to iterate this version that I did for pribeh takes the name of the image file and makes it the title for the photo node.

macuhail’s picture

Thanks guys. This will be a big help. We will be glad to help any way we can with the final version.

pribeh’s picture

Hey gateway69, any chance you'd be interested in porting this module to work with FBSS 3.x/FBSMP 2.x ? There are two issues that are cropping up for sites I'm working on:

- the content author is not taken from the UID of the status creator. Content author ends up being anonymous.
- the attachment is no longer being themed to link to the corresponding node.

pribeh’s picture

Version: 6.x-1.x-dev » 6.x-2.0-rc1
pribeh’s picture

Version: 6.x-2.0-rc1 » 6.x-1.x-dev

Actually, I've rethought this and since FBSS 3.x has page support I don't think this is even necessary if using FBSS 3.x and FBSMP 2.x.

GRodafinos’s picture

sub

bluecobalt’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev

Hey gateway69, did you ever port this module to work with FBSS 3.x/FBSMP 2.x ?

doors’s picture

I had to change one thing in the fbsmp_node_fbsmp_save($status) function.

You initially tried to set $uid = $status->uid; which didn't work for me and the posts were being created by anonymous. So I added global $user; and set $uid = $user->uid; which would get the id of the currently logged in user which is what is needed.

See code changes below:

function fbsmp_node_fbsmp_save($status) {

  global $user; // Adrian: I added this because using the $uid = $status->uid; doesn't returns an id

  if ($status->attachment->type == 'photo') {
     
    // grab the settings from the photo plug, parse out what the user set for gallery and node to save as
    $node_type = variable_get('fbsmp_photo_node', '');
    $field_name = variable_get('fbsmp_photo_field', '');
    $field_name = trim($field_name);
    
    $file_name =  "$field_name[0]['list']"; 
        
    $fid = $status->attachment->data['fid'];        
    //$uid = $status->uid;
    $uid = $user->uid; // Adrian: I made this addition and commented out the line above which wasn't working
    
        // get the filename from the fid, parse our the extension
        // use this as the title of the  node
        $filename = fbsmp_node_filename_get($fid);
        $filename = explode(".", $filename);
        $filename = $filename[0];

    // get all the fields from the node type returned
    // we want to make sure that this node has a fid
    $info = content_types($node_type);
    
    // build a new object to save to the node thats related to your image.
    $file_new = new stdClass();
    $file_new->body = '';   
        $file_new->title = $filename;
    $file_new->type = $node_type;   // Your specified content type
    $file_new->created = $time;
    $file_new->changed = $time;
    $file_new->status = 1;
    $file_new->promote = 0;
    $file_new->sticky = 0;
    $file_new->format = 1;       // Filtered HTML
    $file_new->uid = $uid; // UID of content owner
    $file_new->{$field_name}[0]['list'] = 1; 
    $file_new->field_gallery[0]['nid'] = 1; // the gallery you want all images to be associated with for the user
    $file_new->{$field_name}[0]['fid'] = $fid;  // associated fid for which file was saved in the files table

    // of course you could add in more fields, title, description 
    
    node_save($file_new);  
      
    $nid = $file_new->nid;
    $sid = $status->sid;

    // Save the node id created by node save to the fbsmp table
    // Could be a better way to do this, but for now required additional field nid in table fbsmp
    fbsmp_node_nid_save($nid, $sid);
    
  }
 
}
doors’s picture

I got it working. Just add the following in the code:

    $def_gallery_id = db_query("SELECT nid FROM {node_gallery_default} WHERE uid = '" . $user->uid . "'");
    $def_gallery_row = db_fetch_object($def_gallery_id);

    $file_new->gid = $def_gallery_row->nid;