TinyPortal

Development => Support => Older SMF versions => Topic started by: wulbs on July 21, 2010, 06:52:10 PM

Title: How to turn the News Block into a News Fader.
Post by: wulbs on July 21, 2010, 06:52:10 PM
I tried to use the news block in TP but news fader won't work.

Please help....

I am using:
SMF 1.1.9
TP v.1.05

Title: Re: How to turn the News Block into a News Fader.
Post by: ZarPrime on July 22, 2010, 08:19:54 AM
Hi wulbs,

Welcome to the TP Support Site.

The code below in a php block should work fine for every version of TinyPortal up to and including TP 1.0 beta 4.  It may or may not work with the latest SMF and TP (haven't tried it).  This snippet is located somewhere in our Bloc Code Snippets board, probably in a couple of places, so you probably could have found it by doing a search.

ZarPrime

Code: [Select]
global $context, $settings, $options, $txt, $scripturl, $modSettings;

// Show the news fader?  (assuming there are things to show...)
if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
{
echo '
<div style="height: 40px; background: url('.$settings['images_url'].'/machine.jpg) repeat-x;">';

// Prepare all the javascript settings.
echo '
<div id="smfFadeScroller" style="text-align: center; width: 90%; padding: 2px;"><b>', $context['news_lines'][0], '</b></div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
// The fading delay (in ms.)
var smfFadeDelay = ', empty($settings['newsfader_time']) ? 3000 : $settings['newsfader_time'], ';
// Fade from... what text color? To which background color?
var smfFadeFrom = {"r": 155, "g": 185, "b": 255}, smfFadeTo = {"r": 0, "g": 0, "b": 0};
// Surround each item with... anything special?
var smfFadeBefore = "<b>", smfFadeAfter = "</b>";

var foreColor, backEl, backColor;

if (typeof(document.getElementById(\'smfFadeScroller\').currentStyle) != "undefined")
{
foreColor = document.getElementById(\'smfFadeScroller\').currentStyle.color.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

backEl = document.getElementById(\'smfFadeScroller\');
while (backEl.currentStyle.backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined")
backEl = backEl.parentNode;

backColor = backEl.currentStyle.backgroundColor.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
smfFadeTo = {"r": eval("0x" + backColor[1]), "g": eval("0x" + backColor[2]), "b": eval("0x" + backColor[3])};
}
else if (typeof(window.opera) == "undefined" && typeof(document.defaultView) != "undefined")
{
foreColor = document.defaultView.getComputedStyle(document.getElementById(\'smfFadeScroller\'), null).color.match(/rgb\((\d+), (\d+), (\d+)\)/);
smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

backEl = document.getElementById(\'smfFadeScroller\');
while (document.defaultView.getComputedStyle(backEl, null).backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
backEl = backEl.parentNode;

backColor = document.defaultView.getComputedStyle(backEl, null).backgroundColor.match(/rgb\((\d+), (\d+), (\d+)\)/);
smfFadeTo = {"r": parseInt(backColor[1]), "g": parseInt(backColor[2]), "b": parseInt(backColor[3])};
}

// List all the lines of the news for display.
var smfFadeContent = new Array(
"', implode('",
"', $context['fader_news_lines']), '"
);
// ]]></script><script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/fader.js"></script></div>';
}
Title: Re: How to turn the News Block into a News Fader.
Post by: wulbs on July 22, 2010, 05:19:45 PM
thanks for the quick reply...I will try this now.
Title: Re: How to turn the News Block into a News Fader.
Post by: wulbs on July 22, 2010, 05:28:14 PM
Hi ZarPrime,

I put the the code that you gave to a php block but I doesn't work.

Can you teach me how to use the code that you gave?

Please help. thanks


Title: Re: How to turn the News Block into a News Fader.
Post by: MrCare on November 15, 2010, 08:33:47 PM
is this code show random news?
Title: Re: How to turn the News Block into a News Fader.
Post by: IchBin on November 16, 2010, 08:26:33 AM
It displays the news the same way that SMF does.