1

Sharing on social networks

You can choose which pages are shared, on which networks and how share buttons are displayed and where. The implementation is careful to add just what is needed to a page like the tags in the <head> section of the document which are read by search engines and the code in JavaScript required to interface the server.

Configuration

The type of buttons and the position of the bar for sharing a page on social networks are configured by the parameters $socializing and $socializingmode of the file config.inc.

global $socializing, $socializingmode;

$socializing='either';  // false, 'inline', 'bar', 'either', 'both'
$socializingmode='standard';       // 'standard', 'lite', 'awesome'

If $socializing is inline, the bar is displayed at the end of the content of the page.

If $socializing is bar, the bar floats to the left of the page of the site. If the display is too small, the bar is hidden.

If $socializing is either, the bar floats to the left of the page of the site. It's hidden as soon as the display is too small and replaced by the bar at the end of the content of the page.

If $socializing is both, the bar is always displayed at the end of the content of the page but it also floats to the left of the page if the display is large enough.

If $socializing is false, the bar is not displayed.

If $socializingmode is standard, the bar display the complete buttons buttons generated by the corresponding services. IMPORTANT: In this mode, the JavaScript code of the different providers is loaded on demand by the navigator and the buttons appear progressively. The display takes longer. Some protection modules of the navigators might block the JavaScript and mask the buttons.

With $socializing at bar or at either or both if the display is large enough:

With $socializing at inline or at either or both if the display is not large enough:

The buttons wrap automatically to the next line if necessary:

NOTE: iZend Bootstrap always shows share buttons in the page, i.e. inline, and $socializing can only be set to true or false.

If $socializingmode is lite or awesome, the bar displays buttons which call the interface of the service with a URL. In this mode, no JavaScript code is loaded and run by the navigator. The display is therefore faster but no counter is available. If $socializingmode is lite, the code displays icons in the buttons. If $socializingmode is awesome, the code uses a character font to draw the logos of the services.

To use another set of icons, replace the file social.png in the folder images/theme and edit the CSS for the tags #socialbar and #sharebar in theme.css.

IMPORTANT: When $socializingmode is set to awesome, make sure the CSS file of Font Awesome is loaded by the navigator by editing the view head.phtml:

<?php if (false): ?>
<?php require_once 'ishttps.php'; ?>
<link rel="stylesheet" type="text/css" href="http<?php if (is_https()): ?>s<?php endif; ?>://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" media="screen" >
<?php endif; ?>

You can copy the CSS of Font Awesome in a folder font-awesome in the folder css at the root of the website and modify the URL in the tag <link> in head.phtml.

Editing
Options

Check the boxes facebook twitter google+ linkedin pinit to share the node on Facebook, Twitter, Google+, LinkedIn or Pinterest.

An option for a node is only enabled if the same option is checked for the thread.

Options

NOTE: Options are the same for all languages.

DB

The database records the options for nodes in the table node.

CREATE TABLE `node` (
  `node_id` INT(10) UNSIGNED NOT NULL,
  `user_id` INT(10) UNSIGNED NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `visits` tinyint(1) NOT NULL DEFAULT '1',
  `nocomment` tinyint(1) NOT NULL DEFAULT '0',
  `nomorecomment` tinyint(1) NOT NULL DEFAULT '0',
  `novote` tinyint(1) NOT NULL DEFAULT '0',
  `nomorevote` tinyint(1) NOT NULL DEFAULT '0',
  `ilike` tinyint(1) NOT NULL DEFAULT '1',
  `tweet` tinyint(1) NOT NULL DEFAULT '1',
  `plusone` tinyint(1) NOT NULL DEFAULT '1',
  `linkedin` tinyint(1) NOT NULL DEFAULT '1',
  `pinit` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `node` ADD PRIMARY KEY (`node_id`);
ALTER TABLE `node` MODIFY `node_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;

The options for threads are in the table thread.

CREATE TABLE `thread` (
  `thread_id` INT(10) UNSIGNED NOT NULL,
  `user_id` INT(10) UNSIGNED NOT NULL DEFAULT '1',
  `thread_type` enum('thread','folder','story','book','rss','newsletter') NOT NULL DEFAULT 'thread',
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `number` INT(4) UNSIGNED NOT NULL,
  `visits` tinyint(1) NOT NULL DEFAULT '1',
  `nosearch` tinyint(1) NOT NULL DEFAULT '0',
  `nocloud` tinyint(1) NOT NULL DEFAULT '0',
  `nocomment` tinyint(1) NOT NULL DEFAULT '0',
  `nomorecomment` tinyint(1) NOT NULL DEFAULT '0',
  `novote` tinyint(1) NOT NULL DEFAULT '0',
  `nomorevote` tinyint(1) NOT NULL DEFAULT '0',
  `ilike` tinyint(1) NOT NULL DEFAULT '1',
  `tweet` tinyint(1) NOT NULL DEFAULT '1',
  `plusone` tinyint(1) NOT NULL DEFAULT '1',
  `linkedin` tinyint(1) NOT NULL DEFAULT '1',
  `pinit` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `thread` ADD PRIMARY KEY (`thread_id`);
ALTER TABLE `thread` MODIFY `thread_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
Code

The code in JavaScript is added to the final view standard of the folder layouts in the tag <head> for Pinterest and at the beginning of the tag <body> for Facebook. The views ilike and pinit define the parameters $pinteresetassets and $facebookjssdk. The configuration parameter $facebookid is defined in the file config.inc. For Tweeter, Google+ and LinkedIn, the code is downloaded by adding a tag <script> with the fonction head directly in the views tweetit, plusone and linkedin.

standard.phtml

The code for Pinterest is inserted in the <head> section:

  1. <?php global $pinteresetassets; ?>
  2. <?php if ($pinteresetassets): ?>
  3. <script type="text/javascript">
  4. (function(d){
  5.     var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
  6.     p.type = 'text/javascript';
  7.     p.async = true;
  8.     p.src = '//assets.pinterest.com/js/pinit.js';
  9.     f.parentNode.insertBefore(p, f);
  10. }(document));
  11. </script>
  12. <?php endif; ?>

The code for Facebook is inserted at the beginning of the <body> section:

  1. <?php global $facebookjssdk; ?>
  2. <?php if ($facebookjssdk): ?>
  3. <?php global $facebookid; ?>
  4. <div id="fb-root"></div>
  5. <script type="text/javascript">
  6. window.fbAsyncInit = function() {
  7.     FB.init({
  8. <?php if ($facebookid): ?>
  9.         appId:  '<?php echo $facebookid; ?>',
  10. <?php endif; ?>
  11.         xfbml:  true,
  12.         status: false,
  13.     });
  14. };
  15. (function(d, s, id) {
  16.     var js, fjs = d.getElementsByTagName(s)[0];
  17.     if (d.getElementById(id)) {return;}
  18.     js = d.createElement(s); js.id = id;
  19.     js.src = "//connect.facebook.net/<?php echo $facebookjssdk; ?>/all.js";
  20.     fjs.parentNode.insertBefore(js, fjs);
  21. }(document, 'script', 'facebook-jssdk'));
  22. </script>
  23. <?php endif; ?>
Views
facebook ilike.phtml
twitter tweetit.phtml
google+ plusone.phtml
linkedin linkedin.phtml
pinit pinit.phtml

Comments

To add a comment, click here.