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
.
$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 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
Check the boxes facebook twitter linkedin pinit whatsapp to share the node on Facebook, Twitter, LinkedIn, Pinterest or WhatsApp.
An option for a node is only enabled if the same option is checked for the thread.
NOTE: Options are the same for all languages.
DB
The database records the options for nodes in the 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',
`linkedin` tinyint(1) NOT NULL DEFAULT '1',
`pinit` tinyint(1) NOT NULL DEFAULT '0',
`whatsapp` 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
.
`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',
`linkedin` tinyint(1) NOT NULL DEFAULT '1',
`pinit` tinyint(1) NOT NULL DEFAULT '1',
`whatsapp` 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 and LinkedIn, the code is downloaded by adding a tag <script>
with the fonction head
directly in the views tweetit
and linkedin
.
standard.phtml
The code for Pinterest is inserted in the <head>
section:
- <script>
- (function(d){
- var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
- p.type = 'text/javascript';
- p.async = true;
- p.src = '//assets.pinterest.com/js/pinit.js';
- f.parentNode.insertBefore(p, f);
- }(document));
- </script>
- <?php endif; ?>
- </head>
- <body>
The code for Facebook is inserted at the beginning of the <body>
section:
- <?php global $facebookjssdk; ?>
- <?php if ($facebookjssdk): ?>
- <?php global $facebookid, $facebookapiversion; ?>
- <div id="fb-root"></div>
- <script>
- window.fbAsyncInit = function() {
- FB.init({
- <?php if ($facebookid): ?>
- appId: '<?php echo $facebookid; ?>',
- <?php endif; ?>
- xfbml: true,
- status: false,
- version: '<?php echo $facebookapiversion; ?>',
- });
- };
- (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/<?php echo $facebookjssdk; ?>/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- </script>
Views
ilike.phtml | |
tweetit.phtml | |
linkedin.phtml | |
pinit | pinit.phtml |
Comments