Ok, mission accomplished.
I only used six (or seven :-P) parts:
- First, I've created a new text field for the content type called
facebook_direction.
- Second, I got the facebook script given by Facebook Developers.
- Third, I wrote some PHP code for get the info about the current node
and processing the field values asociated to the node.
- Fourth, I've changed the URL values from the snippet with PHP
code to get every facebook page from every node.
Fifth, I made a new custom block in my Drupal site, called "facebook
stream widget"
Sixth, I've inserted the code in the custom block body with PHP
editor active, marking the block as only for content types of kind
"companies".
Add: I made sure that only the Facebook widget view is created yes and only if the node has completed its field facebook direction. Otherwise, the widget is not generated (line if (!is_null($direction)) ), so it does not show it empty.
Here is the code and works fine:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/es_ES/sdk.js#xfbml=1&version=v2.10";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php
$field = 'field_facebook_direction';
$node = menu_get_object();
$items = field_get_items('node', $node, $field);
$direction = $items[0]['value'];
if (!is_null($direction)) {
?>
<div class="fb-page" data-adapt-container-width="true" data-hide-
cover="false" data-href="<?php
echo $direction;?>" data-show-facepile="false" data-small-
header="false" data-tabs="timeline">
<blockquote cite="<?php echo $direction;?>" class="fb-xfbml-parse-
ignore">
<a href="<?php echo $direction;?>">Facebook Stream</a></blockquote>
</div>
<?php
}
?>
Greetings from Seville! :-)