News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

News Fader No Collapse?

Started by Grammy, June 09, 2016, 09:00:43 AM

Previous topic - Next topic

Grammy

I promise I'm almost done tweaking.   :)

2.0.11 default

I can't seem to find a setting to keep the news fader from being collapsible.  Is that going to be a file edit?  If so, can you guys point me to the right place? 

Thanks! 

Antechinus

You want the most basic version or the most thorough? Can do edits for either.

Antechinus

Meh. Might a well do the lot since I'm waiting on something else anyway. :)

Ok, the file you want is BoardIndex.template.php. The news fader code is here:

// Show the news fader?  (assuming there are things to show...)
if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
{
echo '
<div id="newsfader">
<div class="cat_bar">
<h3 class="catbg">
<img id="newsupshrink" src="', $settings['images_url'], '/collapse.gif" alt="*" title="', $txt['upshrink_description'], '" align="bottom" style="display: none;" />
', $txt['news'], '
</h3>
</div>
<ul class="reset" id="smfFadeScroller"', empty($options['collapse_news_fader']) ? '' : ' style="display: none;"', '>';

foreach ($context['news_lines'] as $news)
echo '
<li>', $news, '</li>';

echo '
</ul>
</div>
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/fader.js"></script>
<script type="text/javascript"><!-- // --><![CDATA[

// Create a news fader object.
var oNewsFader = new smf_NewsFader({
sSelf: \'oNewsFader\',
sFaderControlId: \'smfFadeScroller\',
sItemTemplate: ', JavaScriptEscape('<strong>%1$s</strong>'), ',
iFadeDelay: ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], '
});

// Create the news fader toggle.
var smfNewsFadeToggle = new smc_Toggle({
bToggleEnabled: true,
bCurrentlyCollapsed: ', empty($options['collapse_news_fader']) ? 'false' : 'true', ',
aSwappableContainers: [
\'smfFadeScroller\'
],
aSwapImages: [
{
sId: \'newsupshrink\',
srcExpanded: smf_images_url + \'/collapse.gif\',
altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
srcCollapsed: smf_images_url + \'/expand.gif\',
altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
}
],
oThemeOptions: {
bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
sOptionName: \'collapse_news_fader\',
sSessionVar: ', JavaScriptEscape($context['session_var']), ',
sSessionId: ', JavaScriptEscape($context['session_id']), '
},
oCookieOptions: {
bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
sCookieName: \'newsupshrink\'
}
});
// ]]></script>';
}


Removing this line will get rid of the expand/collapse icon:

<img id="newsupshrink" src="', $settings['images_url'], '/collapse.gif" alt="*" title="', $txt['upshrink_description'], '" align="bottom" style="display: none;" />

That's the most basic version. The catch is that if someone has it collapsed when you make the change, they'll never see the news again. It also leaves redundant code in the template. So you really ought to change this:

<ul class="reset" id="smfFadeScroller"', empty($options['collapse_news_fader']) ? '' : ' style="display: none;"', '>';

To this:

<ul class="reset" id="smfFadeScroller">';

And while you're at it, might as well get id of the superfluous javascript by removing this:

// Create the news fader toggle.
var smfNewsFadeToggle = new smc_Toggle({
bToggleEnabled: true,
bCurrentlyCollapsed: ', empty($options['collapse_news_fader']) ? 'false' : 'true', ',
aSwappableContainers: [
\'smfFadeScroller\'
],
aSwapImages: [
{
sId: \'newsupshrink\',
srcExpanded: smf_images_url + \'/collapse.gif\',
altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
srcCollapsed: smf_images_url + \'/expand.gif\',
altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
}
],
oThemeOptions: {
bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
sOptionName: \'collapse_news_fader\',
sSessionVar: ', JavaScriptEscape($context['session_var']), ',
sSessionId: ', JavaScriptEscape($context['session_id']), '
},
oCookieOptions: {
bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
sCookieName: \'newsupshrink\'
}
});


So the finished code would all look like this:

// Show the news fader?  (assuming there are things to show...)
if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
{
echo '
<div id="newsfader">
<div class="cat_bar">
<h3 class="catbg">
', $txt['news'], '
</h3>
</div>
<ul class="reset" id="smfFadeScroller">';

foreach ($context['news_lines'] as $news)
echo '
<li>', $news, '</li>';

echo '
</ul>
</div>
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/fader.js"></script>
<script type="text/javascript"><!-- // --><![CDATA[

// Create a news fader object.
var oNewsFader = new smf_NewsFader({
sSelf: \'oNewsFader\',
sFaderControlId: \'smfFadeScroller\',
sItemTemplate: ', JavaScriptEscape('<strong>%1$s</strong>'), ',
iFadeDelay: ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], '
});
// ]]></script>';
}

Grammy

Woo hoo!!  I am in News Fader Bliss! 


Thanks, Antechinus!   :D

Advertisement: