エントリー

twitterに記事を紹介してもらうボタン

Freoのカスタマイズ例。

20100704_010.png

あんまり利用者はいなさそうですし解説するほどでもないんですが一応小ネタとして。

  • templates/internals/default/default.html
  • templates/internals/category/default.html
  • templates/internals/entry/default.html
  • templates/internals/view/default.html

この4つのファイルの以下のソース

<li><a href="{$freo.core.http_file}/view/{if $entry.code}{$entry.code}{else}{$entry.id}{/if}#trackback" title="No.{$entry.id}のトラックバック">トラックバック({$plugin_trackback_counts[$entry.id]})</a></li>
<!--{/if}--> !!!ここの間!!!
<!--{if $freo.user.authority == 'root' or $freo.user.id == $entry.user_id}-->
<li><a href="{$freo.core.http_file}/admin/entry_form?id={$entry.id}"><img src="{$freo.core.http_url}images/icons/edit.png" alt="編集" title="編集" width="16" height="16" /></a></li>

「!!!ここの間!!!」と書いたところに↓を挿入

<li><a href="http://twitter.com/home?status={$freo.config.basis.title}&nbsp;-&nbsp;{$entry.title}&nbsp;{$freo.core.http_file}/view/{$entry.id}">この記事をtwitterに投稿</a></li>

twitterにログインした状態なら、「サイト名 - 記事タイトル http://記事URL」と投稿欄内に自動挿入されます。
この記事の場合こんなかんじになる。投稿前に編集ももちろん可能です。

上のサンプル画像はアイコンいれたもの。
俺が作った奴はこれなのでご自由にどうぞ。透過GIF。
20100704_012.gif

アイコンの場合のソースは

<li><a href="http://twitter.com/home?status={$freo.config.basis.title}&nbsp;-&nbsp;{$entry.title}&nbsp;{$freo.core.http_file}/view/{$entry.id}"><img src="ボタン画像のURL" alt="この記事をtwitterに投稿" title="この記事をtwitterに投稿" width="13" height="16"></a></li>

アンカーリンクの際twitterのURLに、home?status= とつけてあったら、それ以降の文字列が投稿が投稿されるようになってるので、そこにFreoの変数を入れただけ。自分でFreoカスタマイズできる人ならたぶん解説すらいらないと思います。
ちなみにこの記事の時点でFreoは0.10.0ですー。

ページ移動

関連エントリー

トラックバック

TrackbackURL

http://don.soraaki.blue/trackback/79