Created
March 19, 2012 15:32
-
-
Save katzueno/2116372 to your computer and use it in GitHub Desktop.
Japanese social bookmark and Open Graph set up for concrete5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php ////////// ?> | |
<?php // Head タグに設置する Open Graph の設定 ?> | |
<?php ////////// ?> | |
<?php $CurrentURL = BASE_URL . DIR_REL . View::getViewPath() . '/'; | |
global $c; | |
// ページタイトルを取得 | |
$pageTitleforSocial = htmlspecialchars($c->getCollectionName(), ENT_COMPAT, APP_CHARSET); | |
// ページ・サムネイルのページ属性 thumbnail を取得 | |
$PageThumbnaillfb = LibraryFileBlockController::getFile($c->getAttribute('thumbnail')->fID); | |
$PageThumbnailSrc = $PageThumbnaillfb->getURL(); | |
if ($PageThumbnailSrc == BASE_URL . DIR_REL . '/files/') { | |
$PageThumbnail = BASE_URL . DIR_REL . '【ここにサムネイル画像が指定されていない場合のデフォルトの画像URL】'; | |
} else if ($PageThumbnailSrc) { | |
$PageThumbnail = $PageThumbnailSrc; | |
} else { | |
$PageThumbnail= BASE_URL . DIR_REL . '【ここにサムネイル画像が指定されていない場合のデフォルトの画像URL(上と同じ)】'; | |
} | |
?> | |
<meta property="og:title" content="<?php echo $pageTitle; ?>" /> | |
<meta property="og:type" content="website" /> | |
<meta property="og:description" content="<?php echo SITE;?>" /> | |
<meta property="og:site_name" content="<?php echo $pageDescription;?>" /> | |
<meta property="og:image" content="<?php echo $PageThumbnail ?>" /> | |
<meta property="og:url" content="<?php echo $CurrentURL;?>" /> | |
<meta property="fb:app_id" content="【ここにFacebook App ID】" /> | |
<?php ////////// ?> | |
<?php // <body>タグの直後に設置するコード ?> | |
<?php ////////// ?> | |
<div id="fb-root"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : '【ここにFacebook App ID】', | |
status : true, // check login status | |
cookie : true, // enable cookies to allow the server to access the session | |
xfbml : true // parse XFBML | |
}); | |
}; | |
(function() { | |
var e = document.createElement('script'); | |
e.src = document.location.protocol + '//connect.facebook.net/ja_JP/all.js'; | |
e.async = true; | |
document.getElementById('fb-root').appendChild(e); | |
}()); | |
</script> | |
<?php // ここから、ソーシャルブックマークを設置する場所に設置するコード ?> | |
<?php | |
global $c; | |
$CurrentURL = BASE_URL . DIR_REL . View::getViewPath() . '/'; | |
?> | |
<p class="socialbtns"><a href="http://twitter.com/share" class="twitter-share-button" data-text="<?php echo htmlspecialchars($c->getCollectionName(), ENT_COMPAT, APP_CHARSET); ?>" data-count="horizontal" data-url="<?php echo $CurrentURL;?>" data-via="【Twitter ID】" data-lang="ja">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <a href="http://b.hatena.ne.jp/entry/<?php echo $CurrentURL;?>" class="hatena-bookmark-button" data-hatena-bookmark-title="<?php echo htmlspecialchars($c->getCollectionName(), ENT_COMPAT, APP_CHARSET); ?>" data-hatena-bookmark-layout="standard" title="このエントリーをはてなブックマークに追加"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a><script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script> <fb:like layout="button_count" show_faces="false"></fb:like> <g:plusone href="<?php echo $CurrentURL;?>" size="medium"></g:plusone> <a href="http://mixi.jp/share.pl" class="mixi-check-button" data-key="【Mixi チェックインのAPIキー】">Check</a><script type="text/javascript" src="http://static.mixi.jp/js/share.js"></script></p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment