MODx片段:Tweet这个
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MODx片段:Tweet这个相关的知识,希望对你有一定的参考价值。
This snippet returns a link to twitter for the user to tweet the current page. URL is TinyURLed automatically (and tinyurls are cached indefinitely in assets/cache/tweetthis.txt).Simply paste code into a new snippet called "TweetThis". Call it like so:
[[TweetThis? &name=\`@DaveChild\` &text=\`Tweet This!\` &id=\`7\` ]]
All parameters are optional. ID defaults to current document.
<?php /** * @name TweetThis * @author Dave Child <[email protected]> * @license GPLv3 * @version 0.3 * * This snippet returns a link to twitter for the user to tweet the current * page. URL is sent through TinyURL automatically (TinyURLs are cached * indefinitely in assets/cache/tweetthis.txt). Link is given the class * "tweetthis". * * &name=`@DaveChild` * Pass through a name to the snippet. You can use your own Twitter ID by * prefixing the name with an @. Optional. * * &text=`Tweet This!` * Text to use for the link. Optional. * * &id=`7` * Document ID (defaults to current document). Optional. */ // --------------------------------------------------- // Check input variables // --------------------------------------------------- // --------------------------------------------------- // Get document information // --------------------------------------------------- $thisDoc = $modx->getPageInfo($id); // --------------------------------------------------- // Define getTinyUrl function // --------------------------------------------------- function getTinyUrl($id) { global $modx; $cacheFile = $modx->config['base_path'] . 'assets/cache/tweetthis.txt'; if ($tinyurls[$id]) { return $tinyurls[$id]; } } else { } $url = $modx->makeUrl($id, '', '', 'full'); if ($tinyurl) { $tinyurls[$id] = $tinyurl; } else { return $url; } return $tinyurl; } } // --------------------------------------------------- // Build link // --------------------------------------------------- $strTweetThis = '<a class="tweetthis" href="http://twitter.com/home?status=' . urlencode($thisDoc['pagetitle']); if ($name <> '') { } return $strTweetThis; ?>
以上是关于MODx片段:Tweet这个的主要内容,如果未能解决你的问题,请参考以下文章