Welcome to Geeklog, Anonymous Thursday, April 10 2025 @ 08:36 pm EDT
Geeklog Forums
Twitter Block Plugin Autotag Hack
Status: offline
Laugh
Site Admin
Admin
Registered: 09/27/05
Posts: 1475
Location:Canada
Here is a quick hack to allow the Twitter Block to be used as an autotag called twitter_block. You can also pass a parameter to postion the block left, center or right.
Replace the plugin_autotags_twitter_block with:
function plugin_autotags_twitter_block($op, $content = '', $autotag = '')
{
global $_CONF, $_TABLES, $LANG_TWITTER_BLOCK_1;
if ($op == 'tagname') {
return array('twitter_link', 'twitter_block');
} elseif ($op == 'parse') {
if ($autotag['tag'] == 'twitter_block' ) {
if (!empty ($autotag['parm1'])) {
$paramater = COM_applyFilter($autotag['parm1']);
if (empty($paramater)) {
$style = '';
} else {
switch ($paramater) {
case "right";
$style = 'style="float:right;clear:both;margin:0px 10px 10px 10px;"';
break;
case "left";
$style = 'style="float:left;clear:both;"';
break;
case "center";
$style = 'margin-left:auto;margin-right:auto;';
break;
default;
$style = '';
break;
}
}
}
$retval = '<div id="tweet" ' . $style . '></div>'; //phpblock_twitter_block();
$content = str_replace ($autotag['tagstr'], $retval, $content);
} else if ($autotag['tag'] == 'twitter_link') {
$tid = COM_applyFilter($autotag['parm1']);
if (! empty($tid)) {
$url = $_CONF['site_url'] . '/twitter_block/index.php?item=' . $tid;
if (empty($autotag['parm2'])) {
$linktext = 'Twitter Block'; // or get title from db
} else {
$linktext = $autotag['parm2'];
}
$link = COM_createLink($linktext, $url);
$content = str_replace($autotag['tagstr'], $link, $content);
}
}
return $content;
}
}
and then replace the plugin_getheadercode_twitter_block function with
function plugin_getheadercode_twitter_block() {
global $_CONF, $_TW_CONF, $_TABLES;
$headerText = '';
//$result = DB_query("SELECT is_enabled FROM {$_TABLES['blocks']} WHERE name = 'twitter_block' LIMIT 1", 1);
//$row = DB_fetchArray($result);
//if ($row['is_enabled']) {
$headerText = "\n".'<!-- Begin twitter_block http://www.flashyourweb.com Javascript and CSS includes -->'."\n";
$headerText .= '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>'."\n";
$headerText .= '<script type="text/javascript" src="'.$_CONF['site_url'].'/twitter_block/index.php?view=javascript"></script>'."\n";
$headerText .= '<link rel="stylesheet" type="text/css" href="'.$_CONF['site_url'].'/twitter_block/index.php?view=css"></script>'."\n";
$headerText .= '<!-- End twitter_block includes -->'."\n";
//}
return $headerText;
}
I don't like loading the java script all the time but currently there is no way to notify Geeklog when a certain script is needed.
Enjoy.
Tom
One of the Geeklog Core Developers.
Replace the plugin_autotags_twitter_block with:
Text Formatted Code
function plugin_autotags_twitter_block($op, $content = '', $autotag = '')
{
global $_CONF, $_TABLES, $LANG_TWITTER_BLOCK_1;
if ($op == 'tagname') {
return array('twitter_link', 'twitter_block');
} elseif ($op == 'parse') {
if ($autotag['tag'] == 'twitter_block' ) {
if (!empty ($autotag['parm1'])) {
$paramater = COM_applyFilter($autotag['parm1']);
if (empty($paramater)) {
$style = '';
} else {
switch ($paramater) {
case "right";
$style = 'style="float:right;clear:both;margin:0px 10px 10px 10px;"';
break;
case "left";
$style = 'style="float:left;clear:both;"';
break;
case "center";
$style = 'margin-left:auto;margin-right:auto;';
break;
default;
$style = '';
break;
}
}
}
$retval = '<div id="tweet" ' . $style . '></div>'; //phpblock_twitter_block();
$content = str_replace ($autotag['tagstr'], $retval, $content);
} else if ($autotag['tag'] == 'twitter_link') {
$tid = COM_applyFilter($autotag['parm1']);
if (! empty($tid)) {
$url = $_CONF['site_url'] . '/twitter_block/index.php?item=' . $tid;
if (empty($autotag['parm2'])) {
$linktext = 'Twitter Block'; // or get title from db
} else {
$linktext = $autotag['parm2'];
}
$link = COM_createLink($linktext, $url);
$content = str_replace($autotag['tagstr'], $link, $content);
}
}
return $content;
}
}
and then replace the plugin_getheadercode_twitter_block function with
Text Formatted Code
function plugin_getheadercode_twitter_block() {
global $_CONF, $_TW_CONF, $_TABLES;
$headerText = '';
//$result = DB_query("SELECT is_enabled FROM {$_TABLES['blocks']} WHERE name = 'twitter_block' LIMIT 1", 1);
//$row = DB_fetchArray($result);
//if ($row['is_enabled']) {
$headerText = "\n".'<!-- Begin twitter_block http://www.flashyourweb.com Javascript and CSS includes -->'."\n";
$headerText .= '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>'."\n";
$headerText .= '<script type="text/javascript" src="'.$_CONF['site_url'].'/twitter_block/index.php?view=javascript"></script>'."\n";
$headerText .= '<link rel="stylesheet" type="text/css" href="'.$_CONF['site_url'].'/twitter_block/index.php?view=css"></script>'."\n";
$headerText .= '<!-- End twitter_block includes -->'."\n";
//}
return $headerText;
}
I don't like loading the java script all the time but currently there is no way to notify Geeklog when a certain script is needed.
Enjoy.
Tom
One of the Geeklog Core Developers.
12
13
Quote
All times are EDT. The time is now 08:36 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content