I am trying to do module with different share buttons in form of field to content type. It has no settings, I just need to enable it in admin panel and the button should appear on node. But I cannot get to work simple sample of code like this:
function fblike_field_info() { return array( 'fblike' => array( 'label' => t('Facebook Like'), 'description' => t('This field displays Facebook Like button.'), 'settings' => array(), 'instance_settings' => array(), 'default_widget' => 'fblike_default_widget', 'default_formatter' => 'fblike_default_formatter', ), ); } function fblike_field_widget_info() { return array( 'fblike_default_widget' => array( 'label' => 'Like Box', 'field types' => array('fblike'), ), ); } function fblike_field_formatter_info() { return array( 'fblike_default_formatter' => array( 'label' => t('Like Box (default)'), 'field types' => array('fblike'), ), ); } function fblike_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $link = '<div class="fb-like" data-href="HTTP://ENTER.YOUR.URL.HERE" data-width="80" data-layout="box_count" data-action="like" data-show-faces="false" data-share="false"></div>'; $element = array(); $element[0] = array('#markup' => $link); return $element; } The result of this code is:
<div class="field field-name-field-lubi-to field-type-fblike field-label-above"> <div class="field-label">Like: </div> <div class="field-items"></div> </div> I already run out of ideas. I have created many modules with fields before, but none was that simple... Am I missing something?