Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

January 22, 2021, 07:15:44 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 191741
  • Total Topics: 20939
  • Online Today: 62
  • Online Ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 39
Total: 39

Author Topic: How to turn the News Block into a News Fader.  (Read 6775 times)

0 Members and 1 Guest are viewing this topic.

wulbs

  • Guest
How to turn the News Block into a News Fader.
« 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


Offline ZarPrime

  • Friends
  • *
  • Posts: 4653
Re: How to turn the News Block into a News Fader.
« Reply #1 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>';
}

wulbs

  • Guest
Re: How to turn the News Block into a News Fader.
« Reply #2 on: July 22, 2010, 05:19:45 PM »
thanks for the quick reply...I will try this now.

wulbs

  • Guest
Re: How to turn the News Block into a News Fader.
« Reply #3 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



Offline MrCare

  • Jr. Member
  • **
  • Posts: 62
Re: How to turn the News Block into a News Fader.
« Reply #4 on: November 15, 2010, 08:33:47 PM »
is this code show random news?

Offline IchBin

  • Developer
  • *
  • Posts: 16231
Re: How to turn the News Block into a News Fader.
« Reply #5 on: November 16, 2010, 08:26:33 AM »
It displays the news the same way that SMF does.