How to show the News box (the big one) on every page of the forum

Started by anrapa2, October 22, 2008, 03:47:15 AM

Previous topic - Next topic

anrapa2

Hello to everyone!
I often use the news box, I noticed there are 2 of them: one is big, with a white background (at least on the unmodified theme) and shows only on the "main page", when you enter any other section or thread it becomes smaller, positioned on the upper left corner, shown with smaller font.
Is there a way to keep always and only the big white box on every page and not only on the main one?
Thanks!

Nathaniel

You should be able to do that, by moving some code from your '/Themes/{themename}/Display.template.php' file to your '/Themes/{themename}/index.template.php' file. Could you please post them?
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Adish - (F.L.A.M.E.R)

I would be interested in here a bit too, can you post the edits is possible instead of doing it for him. ;)

Nathaniel

Okay, here are the edits for the SMF 2 Beta default theme.

Find and remove this code from your '/Themes/default/BoardIndex.template.php' file.
    // Show the news fader?  (assuming there are things to show...)
    if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
    {
    echo '
    <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
        // Create the main header object.
        var smfNewsFadeToggle = new smfToggle("smfNewsFadeScroller", ', empty($options['collapse_news_fader']) ? 'false' : 'true', ');
        smfNewsFadeToggle.useCookie(', $context['user']['is_guest'] ? 1 : 0, ');
        smfNewsFadeToggle.setOptions("collapse_news_fader", "', $context['session_id'], '");
        smfNewsFadeToggle.addToggleImage("newsupshrink", "/collapse.gif", "/expand.gif");
        smfNewsFadeToggle.addTogglePanel("smfNewsFader");
    // ]]></script>
    <div class="tborder marginbottom">
        <h3 id="newsfader" class="catbg headerpadding">
            <a href="#" onclick="smfNewsFadeToggle.toggle(); return false;">
                <img id="newsupshrink" src="', $settings['images_url'], '/', empty($options['collapse_news_fader']) ? 'collapse.gif' : 'expand.gif', '" alt="*" title="', $txt['upshrink_description'], '" align="bottom" />
            </a>&nbsp;', $txt['news'], '
        </h3>
        <div id="smfNewsFader"', empty($options['collapse_news_fader']) ? '' : ' style="display: none;"', '>
            <div id="smfFadeScroller"><span>', $context['news_lines'][0], '</span></div>
        </div>
    </div>
    <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
        // The fading delay (in ms.)
        var smfFadeDelay = ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], ';
        // Fade from... what text color? To which background color?
        var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 255, "g": 255, "b": 255};
        // Surround each item with... anything special?
        var smfFadeBefore = "<b>", smfFadeAfter = "</b>";

        var foreColor, foreEl, 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")
        {

            foreEl = document.getElementById(\'smfFadeScroller\');

            while (document.defaultView.getComputedStyle(foreEl, null).getPropertyCSSValue("color") == null && typeof(foreEl.parentNode) != "undefined" && typeof(foreEl.parentNode.tagName) != "undefined")
                foreEl = foreEl.parentNode;

            foreColor = document.defaultView.getComputedStyle(foreEl, null).getPropertyValue("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).getPropertyCSSValue("background-color") == null && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
                backEl = backEl.parentNode;

            backColor = document.defaultView.getComputedStyle(backEl, null).getPropertyValue("background-color");//.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'], '/scripts/fader.js"></script>';
    }


Find this code from your '/Themes/default/index.template.php' file:
    // The main content should go here.
    echo '
    <div id="bodyarea">';


Add the code that you removed from your 'BoardIndex.template.php' file after that code.

Find this code from your '/Themes/default/index.template.php' file:
    echo '
    <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style', $context['theme_variant'], '.css?b4" />';


Replace with this code:
    echo '
    <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style', $context['theme_variant'], '.css?b4" />
    <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/forum.css?b4" />';
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Adish - (F.L.A.M.E.R)

I havnt tested it yet, but I am sure it will work :)

Thank you very much.


EdwardR

Is it possible to get the same thing for 1.1.7? I'm sick of having both the news in the header and then the news in the fader.

Thanks!

Ed x
You got the best of me ... Now I'm losing it .. Oh Oh Oh la la la oh oh!

Nathaniel

Okay, here are the edits for the SMF 1.1.x default theme.

Find and remove this code from your '/Themes/default/BoardIndex.template.php' file.
    // Show the news fader?  (assuming there are things to show...)
    if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
    {
        echo '
    <table border="0" width="100%" class="tborder" cellspacing="' , ($context['browser']['is_ie'] || $context['browser']['is_opera6']) ? '1' : '0' , '" cellpadding="4" style="margin-bottom: 2ex;">
        <tr>
            <td class="catbg"> &nbsp;', $txt[102], '</td>
        </tr>
        <tr>
            <td valign="middle" align="center" height="60">';

        // Prepare all the javascript settings.
        echo '
                <div id="smfFadeScroller" style="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']) ? 5000 : $settings['newsfader_time'], ';
                    // Fade from... what text color? To which background color?
                    var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 255, "g": 255, "b": 255};
                    // 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>
            </td>
        </tr>
    </table>';
    }


Find this code from your '/Themes/default/index.template.php' file:
    // The main content should go here.
    echo '
    <div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">';


Add the code that you removed from your 'BoardIndex.template.php' file after that code.

If you want to remove the small news area then perform this edit (SMF 1.1.x):
Find and remove this code ('index.template.php'):
    // Show a random news item? (or you could pick one from news_lines...)
    if (!empty($settings['enable_news']))
        echo '
                <td width="90%" class="titlebg2">
                    <span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
                </td>';
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

C4G-TK

Quote from: Nathaniel on November 02, 2008, 06:37:31 AM
Find this code from your '/Themes/default/index.template.php' file:
    echo '
    <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style', $context['theme_variant'], '.css?b4" />';


Replace with this code:
    echo '
    <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style', $context['theme_variant'], '.css?b4" />
    <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/forum.css?b4" />';


Thanks!  I tried this as well and it worked like a charm after I remembered to replace the b4" in the codes above to rc1"!!

-img removed-

Advertisement: