CVS edit link for Durrok

Created a simple drupal model thats creates a block with a few options for the new Facebook recommend/like button. You can see it in action at http://www.wagist.com/.

Comments

Durrok’s picture

FileSize
1.83 KB

Attached is the module.

Durrok’s picture

FileSize
1.83 KB

Of course as soon as I upload it I find a bug. :P Use this one instead.

kiamlaluno’s picture

Status: Postponed (maintainer needs more info) » Needs work
Issue tags: +module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

As per http://drupal.org/cvs-application/requirements, the motivation message should be expanded to contain more details about the features of the proposed module, and it should include also a comparison with the existing solutions. As I can recall, there is already a project with a similar purpose.

Durrok’s picture

It adds a block with the new Facebook recommend/like button. There are options on the block as to display the button as like or recommend and whether or not to show faces. As far as similar functionality this just came out yesterday, no one has anything for it yet. I had a friend of mine ask me how he could add it to his blog. I created the module with ease of use in mind and is aimed at non-technical Drupalers (like my friend) who would have trouble configuring this by themselves.
EDIT: It also takes care of getting the correct url of the page instead of you having to go and copy it in every time or go back and change it if the url changes.

There is a Facebook for Drupal module but that module does not offer this functionality and is far larger in scope then this.

Even if you do not want to add this module in I would really appreciate any feedback on the code.

Thanks,
Durrok

Durrok’s picture

FileSize
2.29 KB

Not sure why the tar.gz file did not upload correctly... trying with just zip. There we go, zip upload correctly. Strange.

Anonymous’s picture

Status: Needs work » Needs review
Durrok’s picture

http://drupal.org/node/782810 has submitted a similar module. Proposed we collaborate and combine our modules.

sun’s picture

Durrok’s picture

Sun - Well after reading over that thread on CVS submissions I can tell that this is not something you will likely not want to create a separate module for. However, entertain me for a moment. If we look at the modules:

Drupal for Facebook is definitely out, it's designed for programmers, specific those who want to program Facebook applications that integrate in with their site.

Fbconnect is closer, but the install is daunting to casual users and you may not want the Facebook connect functionality on your site.

Ideally this module should be included with the fbconnect module but also available on it's own. That way if you want the whole package it's easy to get and available in one place. If you just want a simple like/recommend button that is available through grabbing just this module.

So the million dollar question: Since there is a module out there that offers related features (but not these features specifically) do we force users to go "all or nothing" or do we package the modules together and offer it as a stand alone module as well?

sun’s picture

Did you ask one of those maintainers whether this (basic) functionality could be included, potentially as sub-module like you mentioned?

Adding yet another module for almost the same purpose... will ultimately lead to: feature requests. Feature requests turn into patches turn into code turn into more features, effectively turning an originally intended to be "basic" module into a full duplication of efforts.

Durrok’s picture

Of course not, that is why I asked how to proceed. I have sent him a message asking how he would like to handle this feature.

Trust me, I have no problems pointing people to an existing module. I don't mind tweaking things or fixing issues but I have far bigger projects I am working on.

I also noticed Joomla and Wordpress had modules/extensions/whatever they call them out for this day one it was released (4/22), while Drupal still does not have this functionality. This feature is very popular with almost every social site/blog, yet if your site runs Drupal and you are not a programmer you do not have the option to include this feature and with the way this process works you likely won't for some time to come. Why do our "competitors" have no problem getting a simple feature out on day one while we lag behind or at best, if we follow protocol, require them to jump through several hoops and install several functions on their site that they may not want to accomplish the same thing?

I understand your concerns. There has to be a better way though.

sun’s picture

Ideally create some public issues for those projects, please. Therefore, the question will not only be discussed and answered for you, but also for others. And ultimately, if none of the existing projects consider to accept it, then you are able to point to publicly available evidence that it wasn't doable.

sun’s picture

Durrok’s picture

Sun - Where should I create these public issues? On the existing Facebook projects?

dzkatz’s picture

I'm not familiar with the process for creating modules and am a very casual user, but I'm very interested in a module that will allow my site's users to "like" specific content. I tried installing Durrok's module above with limited success. It looks like its moving in the right direction and he has a good point - other CMS have this feature and Drupal should add one ASAP!

thanks

sun’s picture

@Durrok: exactly - project issues are used for everything on drupal.org.

Durrok’s picture

dzkatz - If something didn't work for you please let me know. I am obviously just starting out, any feedback would be greatly appreciated.

Sun - Created a thread over on the fbconnect project.

HS’s picture

Get this going folks, please. Drupal is always way behind other CMS when it comes to keeping up with developments in the social networking world.

scottholmes’s picture

I looked over the code in the module and went ahead and installed it. I've noted that as the button as described by Facebook uses iframe, it is not compatible with Strict coding standards. I've taken the liberty and modified it to use the object tag instead. The code validates and seems to function using firebox and chrome. Neither the original nor my modified version works with IE6 (the only version I have immediately available save for Firefox's emulation of IE). The only change I made was thus:

	$link = t('<object type="text/html" data="http://www.facebook.com/plugins/like.php?href='.$url.'
				&amp;layout=standard&amp;show_faces='.$faces.'&amp;width=450&amp;action='.$like_recommend.'
				&amp;colorscheme=light" height="60px" width="450px" border="0" overflow="hidden"/>');
sun’s picture

@Durrok, thanks for your patience! You've shown a great reaction and started to collaborate with others. I'm therefore certain that we can happily approve your application.

However, there was no code review yet, so I need to ask you fix the following issues before we can proceed:

				'#default_value' => variable_get('face_setting', 0),

Variables have to be in the namespace of the module, i.e. facebook_recommend_setting.

				'#default_value' => variable_get('like_recommend_setting', 0),
...
			variable_set('face_setting', $edit['face_setting']);
			variable_set('like_recommend_setting', $edit['like_recommend_setting']);

Same here.

			$tempURL = implode(arg(), "/");
			$url = $base_url.'/'.urlencode(drupal_get_path_alias($tempURL));

This needs to be replaced with:

$url = url($_GET['q']);
			$link = t('');

1) The URL for the "src" attribute has to be properly built with url(), too.

2) For all other attributes, you likely want to use drupal_attributes().

3) t() is entirely wrong here. And the entire HTML string should be output in the theme function instead - so instead of passing a string to the theme function, you should pass an array of attributes for the iframe.

4) Regardless of where this is output, the final URL string in the "src" attribute needs to be wrapped with check_url().

Please make yourself familiar with Drupal's APIs for security and output sanitization.

			$block['subject'] = t('');

t() should never be used on an empty string. You can drop the whole line if you do not want to output a subject.

function facebook_recommend_theme() {
	return array('facebook_recommend' => array(
		'arguments' => array(
			$link => NULL)
		)
	);

The arguments array is bogus. $link is not defined here. Please make yourself familiar with hook_theme().

In addition, it sounds like you'd already have a couple of contributors for this module :) Would be great to see all of you join forces here.

Brian Altenhofel’s picture

@Durrok - Would you be interested in teaming up on this?

Recently, I completed a module to add the new Facebook Like Button to nodetypes that the site admin may select. It also has the option to display this feature in a block with independent settings. It can be seen in action at http://www.altenhofel.com and http://www.vmdoh.com. A screenshot of the admin interface is available at http://www.vmdoh.com/likebutton-ss.gif.

I know there are at least two Facebook modules in contrib already, but I think that both of these are too bulky or technical for the average user who may want to add a "Like" button.

Drupal for Facebook seems more geared towards Facebook application developers looking to integrate Drupal with their application, which is much more than the average user needs.

FBConnect requires an application and API key on Facebook to use, and that is too technical for some users who only desire to be able to add the "Like" button. Many users would rather just plug-and-play.

I understand the reasoning about attempting to place the majority of Facebook integrations under one module, but I think a widget like this is in an entirely different league than an application. These are two separate target audiences - one likes to tweak (devs), and the other likes to download and go (bloggers, small business owners, etc).

To use the "Like" button widget from Facebook, you don't need an API key or an application. All you need is a little bit of code conveniently provided by Facebook. No app. No API key. Very little overhead. (Copied from my CVS application on http://drupal.org/node/786812 with a few changes)

The primary difference between my module and Durrok's is that his is limited to a block while mine allows you to independently configure one to be in a block (i.e. in a sidebar) and another to appear immediately after the node's content. For the one appearing right after the node's content, there are options on the admin page to select nodetypes and Full View, Teaser, or Both. My module also includes Facebook's META data (og:image, og:title, and og:site_name) which allows for friendly links in the Facebook newsfeed.

sun’s picture

Thanks! It would be awesome to see both of you joining forces to build that module. I'm inclined to approve both of your applications, so you can move forward with merging both attempts into a new, co-maintained project. However, we definitely have to rule out the critical issues I mentioned above. :)

Brian Altenhofel’s picture

Here's an attempt at a merge of the two, including the concerns mentioned above by sun.

filiptc’s picture

Testing #23 (& subscribing).

dzkatz’s picture

I tried this version and found it was a step backwards from Durrok's orignial. When I enable this module and add to the conent block, all I see when I load the page is FACEBOOK RECOMMEND in bold letters on the page - theres no other text like, "click here to like" etc... Thanks to everyone working on this!

mandclu’s picture

subscribing. Great to see some progress being made on this front.

filiptc’s picture

I was pretty happy with the functionality of #23. Cannot agree with #25, everything is configurable at admin/settings/facebook_recommend.

Couple of things:
1) Append a css to the module to make theming easier.
2) Block is approx. 80px high which below each teaser takes a huge space and kills the visual flow of the page. If possible, make the height configurable (just like the width).

I added the following to my css:

.facebook_recommend {
  height:35px;
  text-align:right;
}

Cheers!

filiptc’s picture

Forgot, if you don't fill out the Thumbnail section in the preference page and hit submit, it uses the front page path as source for the thumbnail instead of just omitting that feature.

filiptc’s picture

Sorry, I'll just keep the feedback coming.

When showing the like button in teaser mode in a node listing, hitting one of the buttons triggers all to be marked as 'liked' (I guess it takes the listing's $url as 'liked'). It would make more sense to use the node's $url as the "href" value even though it's not the current $url to avoid this behavior.

scottholmes’s picture

In order to remain compliant with Strict standards, the meta tag "property" attribute needs to be changed to "name" and the "border" and "overflow" attributes need to be moved to CSS somehow. Currently, I've just eliminated them.

toodlepip’s picture

FileSize
9.61 KB

Argh! Wish I'd seen this thread earlier.

Just finished writing a similar module to the one(s) you guys have been talking about. I've attached the ZIP file for reference in case any of its useful.

I've only had the briefest of glances at the current code (it's pretty late here) and there's a couple of differences:

  • Option to disable addition of META tags
  • Adds FB like button to $links with option to turn off
  • Stand-alone theme('fb_like', $node) for user's to add to their templates
  • Uses FB Javascript call instead of iframes (supposedly more features for this method coming)

Other than that, it's pretty much identical. Uploading the code for reference as much as anything else.

FWIW, I agree with the earlier thread about having a simple module to add the button to Drupal posts. The other modules are a bit more industrial and we've been after something simple, but with more flexilibty than just hard-coding the buttons into templates.

Other stuff I'd like to add:

  • Option to include FB Like buttons based on taxonomy terms
  • Option to tailer OG Meta Tags based on token replacements (might be overkill)
  • Only call in FB Javascript code on pages where buttons are used
  • Options for the other recently-deployed FB widgets

Let me know if I can help on the dev side.

Toodle Pip

Sam

Brian Altenhofel’s picture

FileSize
12.65 KB

To use the FB Javascript, at least the way I understand it, you have to create a Facebook Application at http://developers.facebook.com/setup/. I know that is rather simple for most people to understand, but one thing to consider is there will likely be Drupal users who just want to add the Like button feature without any extra steps. Maybe we could make that optional? As in if you have a FB App ID for the JS, then the user would be able to use an "extended" version? Just thinking out loud here.

Also, I like the idea of adding it to $links on the teasers. We should probably set up another config for that, so that if the user wants button_count rather than standard to save space in the teaser.

I don't have time to get to that tonight (Monday evenings are quite busy for me through July, which is why I haven't posted until now), but I've attached a new ZIP addressing the concerns of @filip_tc and @scottholmes

dzkatz’s picture

Hi, I reinstalled #23 verson and got it to work on my site. With one problem that I had with the original Durrok version. Right now I have the configuration set to display the Like button on each page on my site. When I click the button on one page it doesn't just add my "Like" to that page, it adds it to all pages. To clarify, it appears that I clicked the individual like buttons on each page, when I really only clicked it once on one page. Is there a configuration or setup that I missed?

FYI, i'm using Firefox 3.6.3 for Windows.

filiptc’s picture

@dzkatz: I guess it's the same issue as my last post #29.

ferdi’s picture

Please have a look at http://drupal.org/project/fb_social .

dzkatz’s picture

Thanks Filip, looks to be the same issue...but I don't have any web expertise and don't understand why..hopefully everyone working on this can provide a fix!

Brian Altenhofel’s picture

That should be fixed in #32 (or at least it is on my sandbox and blog). The only thing missing from #32 is drupal_add_css(). It was late, and it just hit me this morning, and I don't have the access to fix it from my day job.

I'm starting to think that we might want to collaborate with ferdi.

One issue I am having trouble figuring out is with the object not automatically expanding with the faces when those are enabled. If we remove the height attribute, we get the huge blank space below.

filiptc’s picture

@Brian Altenhofel: Yes, confirming, fixed.

Right now, only thing "bothering" me is the height thing. Otherwise everything is perfect.

toodlepip’s picture

FileSize
11.09 KB

Good point!

I've updated the code I started working on as it fits the needs for a couple of our sites (live here: http://www.toodlepip.co.uk/). @ferdi's module looks great too, especially the ability to use Facebook's comments, although I'm keen to hang on to data on our site rather than hand everything off to Facebook.

You don't need a Facebook App Id in order to use the code to create a button. However, if you do grab an App Id and set the Connect URL in the App settings, it allows users to (optionally) add comments when they use the 'Like' button. (hat tip @ferdi - been looking for that info for ages, and you're the first to write it down!)

I've updated my version of the module to allow for both an App Id and locale setting. If these are provided the Javascript version is used, otherwise the plain old

tag gets used instead. Feel free to use any of the code in your module. Toodle Pip Sam
hixster’s picture

Toodlepip, thanks for the FB Like button. work great. How tweak it to appear at the node top instead of the bottom?

regards

Hix

dzkatz’s picture

Hi, I tried installing Toodlepip's fb_like module, but am having trouble. There is no readme file so I didn't have exact directions. I uploaded the files to my FTP and enabled the module in administer>site building>modules. However, once I enabled it, I couldn't find a fb_like module in the list at site building>blocks area like i could with the facebook recommend module originally uploaded in this thread. Any help installing this would be great!

Thanks,
Dave

hixster’s picture

@ducats, there no block, the options are in the admin site configuration menu.

Lots of config options for adding button by content type etc...

James Andres’s picture

FileSize
5.22 KB

Hello All,

First off, great collaboration! I'm happy to see the Drupal community working together on this one.

I've done a bit of refactoring on the fb_like module, key areas are:

  • Moved administration forms into a separate file. This is in keeping with D6 and D7 module design philosophy.
  • Cleaned up the .info file (Put the module in the package "Facebook")
  • Renamed the constants with the FB_LIKE namespace prefix. (See the Drupal coding standards, http://drupal.org/coding-standards#naming)
  • Removing trailing ?> from all files
James Andres’s picture

FileSize
5.29 KB

Small addition. I've added a height setting, defaults to 25px. This appears to be okay as Facebook are forcing a height of 25px in their demo.

Exploratus’s picture

Wow. great collaboration - and quick!!!

AppleBag’s picture

Sorry for the dumb question, but is this for D5, D6 or D7?

hixster’s picture

@AppleBag -> D6 :-)

toodlepip’s picture

@hixster, sorry for the delay - work getting in the way of tinkering with the module. Looks like there's lots of developments here, too.

The module I put together, uses Drupal's $links variable in the node template as the standard way to show the FB Like button. If you want to put the button in a different position, use the option in the admin settings:

Administer > Site configuration > Facebook Like

Select the option:

Disable Facebook Like button in $links

Then, insert the button directly into the template using the custom theme function, use the code:

<?php print theme('fb_like', $node); ?>

and the button should turn up. Probably worth including a

round it, to help with styling:
<div class="fb-like">
<?php print theme('fb_like', $node); ?>
</div>

Hope that helps.

toodlepip’s picture

FileSize
7 KB

@hixster @ducats - Good point, added two blocks, one for the Like Button and another for the sitewide Like Box. Also added a README.txt file. Module attached, hope it's useful.

hixster’s picture

@Toodlepip - excellent! Thanks for those mods , i'll give them a try :-)

regards

dzkatz’s picture

Sorry to cause so much trouble here, but can someone walk me through the install? I tried following all the instruction in read me and in the drupal install how-to page linked above but haven't had success.

1. I uploaded all files to fb_like folder in sites/all/modules
2. I enabled the module in admin/build/modules
3. I dragged the fb_like button to the content section in admin/build/bloc, configured to show on all content, and saved.

When i load pages on my site I don't see the facebook button available anywhere. Can anyone see any steps I may have missed or why this module isn't working for me?

Thanks,
Dave

hixster’s picture

@dzkatz - I think you're nearly there. You need to enable which content types the button will show on.
I think the options are in admin/site-configuaration/fb_like. More details in post #48

sun’s picture

It seems like we made some good progress here.

1) Can someone explain the difference and/or considerations regarding http://drupal.org/project/fb_social ? Could this be merged into the existing project and possibly co-maintained or not?

2) Who is going to officially (co-)maintain this code?

James Andres’s picture

+1 for merging / contributing to fb_social. I'd hate to see this great work rust in the issue queue :-)

Cactii1’s picture

That's a LOT of overhead for some stupid Facebook "Like" button...

Try this...

Paste this into your template where you want the "Like" button to appear.

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php global $base_root; echo $base_root . request_uri(); ?>&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

So easy - Maybe that's why there was no rush to make a 0-day module (plugin, extension) for it. ;)

gagarine’s picture

Please create issue instead of +1 ;)

#811326: Merge with facebook like module

I agree with #55 but on the other hand a module open the door to other stuff, API, hook etc, and centralize bug and incompatibility. (see gmap for example...).

ferdi’s picture

The fb_social_like module is part of the fb_social project (http://drupal.org/project/fb_social) and currently has the following features:

- Allows site admins to select which content type will use the like widget
- Allows site admins to customize the widget.
- Allows site admins to control the location of the widget:
-- In the node links area
-- In the node content area. In this case the widget becomes a cck-like field and can be moved up and down like any other cck field
- Creates a block which contain the like widget.
- Adds the necessary metadata to your drupal pages (og:title, og:site_name, og:image)

I'll be more than happy to collaborate / accept patches / add you as a co-maintainer / give the full ownership of the project to you !

todos:

- Implement the non-js version of the like widget
- Complete opengraphprotocol metadata ( waiting for http://drupal.org/node/784904 )
- Ability to create widget presets i.e. ctools integration (maybe)

thanks!

toodlepip’s picture

@ferdi - Would be really happy to collaborate, I'm no expert but happy to contribute as much as I can. Happy to be co-maintainer is that'd help out.

Work is a bit bonkers, so it might be a touch sporadic! I haven't worked on a module on Drupal.org before, so you might have to bear with me as far as the dev process works.

fb_like shares much functionality with fb_social, I think there's a few differences:

  • Option to upload image to include in meta data headers
  • Degrades to
    version if FB AppId isn't available
  • Global Settings for variable_get() also stored in CONSTANTS
  • Option to disable inclusion of FB meta tags
  • Use site_name in meta tags if page name isn't set
  • Specific permission for administering module
  • Inclusion in node links, as default option
Probably more, but got those from a quick flick through. Stuff I'd like to add generally:
  1. Handling of more OG tags (snap! You've mentioned this, too)
  2. Automating the addition of the extra attributes - only got a horrible, hacky idea for doing this (search/replace on page output - yuck!)
  3. Additional modules to handle the other FB plugins
  4. Step-by-step guide to handling the FB registration end of things, it's quite complex and docs need to be dead easy
  5. Caching/throttling for FB code/meta tags/links
Lemme know what you reckon. I'm going to try and write-up a blog post for #4 this weekend, if I get a chance.
fehin’s picture

Post #55 was just what I needed. Thanks Cactii1.

jacobroufa’s picture

There may be a lot of overhead for just a "Like" button, but I just tried to use your simple solution Cactii1 and it worked beautifully until I needed to integrate the button in a view. I'm running a Drupal 5 site and need a "Like" button solution now! :( Maybe I'll try to backport the module in this thread.

EDIT : So very close; just need to figure out the theme-related stuff. Any thoughts as to what to do with the _preprocess_page function and how to get the same functionality in Drupal 5?

kiamlaluno’s picture

Status: Needs review » Needs work
  • This is a review of the code attached to comment #5.
  • The points reported in this review are not in order of importance / relevance.
  • Most of the times I report the code that present an issue. In such cases, the same error can be present in other parts of the code; the fact I don't report the same issue more than once doesn't mean the same issue is not present in different places.
  • Not all the reported points are application blockers; some of the points I report are simple suggestions to who applies for a CVS account. For a list of what is considered a blocker for the application approval, see CVS applications review, what to expect. Keep in mind the list is still under construction, and can be changed to adapt it to what has been found out during code review, or to make the list clearer to who applies for a CVS account.
  1. The module doesn't implement hook_uninstall().
  2. See http://drupal.org/coding-standards to understand how a module should be written. In particular, see how Drupal variables, global variables, constants, and functions defined from the module should be named.
  3. The points reported by sun are still valid.
toodlepip’s picture

@kiamlaluno - good to see an update here. I wrote the alternative version of this module and dropped @ferdi a line ages ago about maintaining/co-maintaing this module. Not sure what the next step should be.

I can amalgamate the two modules taking into account your comments above, but what's the best way to apply for this to get into CVS? Submit a new application or submit the new code in a single ZIP using this thread?

If you could point me in the right direction, it'd be much appreciated. Thanks for your help.

hixster’s picture

but I just tried to use your simple solution Cactii1 and it worked beautifully until I needed to integrate the button in a view.

Hi jacobroufa, i use views customfield to add facebook like buttons to views. D5 is supported too. Just paste the 'like' code into the field and you're all set.

http://drupal.org/project/views_customfield

Durrok’s picture

Status: Needs work » Closed (won't fix)

http://drupal.org/project/fb_social provides everything my module did and more. Just use that. Did not even realize this thread was still open.

jselanikio’s picture

Component: Miscellaneous » miscellaneous
Category: task » support

Can someone explain to me how I can make the text produced by this module wrap within a block. I have the module installed and active but the text ("_____, _____ and 3 others like this.Unlike") runs past the right block margin. Thanks.

Anonymous’s picture

@ jselanikio: This is not the issue queue for a module; this application has been declined, and the module is not in drupal.org repository.