NEW Add method to add social network sharing buttons on blog posts
This commit is contained in:
parent
a2f9f72973
commit
27015fc6f6
@ -652,6 +652,57 @@ function getStructuredData($type, $data = array())
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML content to add structured data for an article, news or Blog Post.
|
||||
*
|
||||
* @return string HTML content
|
||||
*/
|
||||
function getSocialNetworkSharingLinks()
|
||||
{
|
||||
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
|
||||
|
||||
$fullurl = $website->alias.'/'.$websitepage->pageurl.'.php';
|
||||
$hashtags = trim(join(' #', array_map('trim', explode(',', $websitepage->keywords))));
|
||||
|
||||
print '<!-- section for social network sharing of page -->'."\n";
|
||||
print '<div class="dol-social-share">'."\n";
|
||||
|
||||
// Twitter
|
||||
print '<div class="dol-social-share-tw">'."\n";
|
||||
print '<a href="https://twitter.com/share" class="twitter-share-button" data-url="'.$fullurl.'" data-text="'.dol_escape_htmltag($websitepage->description).'" data-lang="'.$websitepage->lang.'" data-size="small" data-related="" data-hashtags="'.preg_replace('/^#/', '', $hashtags).'" data-count="horizontal">Tweet</a>';
|
||||
print '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>';
|
||||
print '</div>'."\n";
|
||||
|
||||
// Reddit
|
||||
print '<div class="dol-social-share-reddit">'."\n";
|
||||
print '<a href="https://www.reddit.com/submit" target="_blank" onclick="window.location = \'https://www.reddit.com/submit?url='.$fullurl.'\'; return false">';
|
||||
print '<img src="https://www.reddit.com/static/spreddit7.gif" alt="Submit to reddit" border="0" /> </a>';
|
||||
print '</div>'."\n";
|
||||
|
||||
// Facebook
|
||||
print '<div class="dol-social-share-fbl">'."\n";
|
||||
print '<div id="fb-root"></div>'."\n";
|
||||
print '<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/en_US/sdk.js#xfbml=1&version=v2.0&appId=dolibarr.org";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, \'script\', \'facebook-jssdk\'));</script>
|
||||
<fb:like
|
||||
href="'.$fullurl.'"
|
||||
layout="button_count"
|
||||
show_faces="false"
|
||||
width="90"
|
||||
colorscheme="light"
|
||||
share="1"
|
||||
action="like" ></fb:like>'."\n";
|
||||
print '</div>'."\n";
|
||||
|
||||
print "\n</div>\n";
|
||||
print '<!-- section end for social network sharing of page -->'."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of containers object that match a criteria.
|
||||
* WARNING: This function can be used by websites.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user