Hide RSS TICKER if no news

Post

Posted
Rating:
Item has a rating of 5 (Liked by Chris Graham)
#1558 (In Topic #319)
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’

display nothing if no news rather than a message saying that

Hello all,

Plugging away on my site adding content everyday and trying to modify things so they will make sense to Japanese folks. One thing I am doing is removing many of the bells and whistles, features etc to make it a super simple site so Japanese people with basic english can navigate.

I am enjoying the side block RSS news ticker by grabbing alerts from google news (they will provide a daily RSS if you want) so it works great mostly except sometimes their engine will include news that is not related but I am sure they will hone that eventually.  anyways, today there was no news and the stock "there is no news" is substituted… So I thought maybe I would just edit that to be a funny quote or image but instead I changed the template to check and not show the ticker at all if no content.  This is the same idea as what I posted the other day.

I should mention that for this RSS ticker I have the defer option ON…..  so as the ste is already loaded it checks to see if content, if so, shows the news, and if no content then moves along and no notices about it.  Major kudos to Chris for having this "defer" option, its powerful and awesome.

 

templates/BLOCK_SIDE_RSS.tpl

{+START,IF,{$NOT,{TICKER}}}
    <section id="tray_{TITLE|}" class="box box___block_side_rss">
        <h3 class="toggleable_tray_title">
            <a class="toggleable_tray_button" href="#" onclick="return toggleable_tray(this.parentNode.parentNode,false,'{TITLE|}');"><img alt="{!CONTRACT}: {$STRIP_TAGS,{TITLE`}}" title="{!CONTRACT}" src="https://compo.sr/themes/composr_homesite/images/1x/trays/contract2.png" srcset="https://compo.sr/themes/composr_homesite/images/2x/trays/contract2.png 2x" /></a>

            {+START,IF_NON_EMPTY,{TITLE}}
                <a class="toggleable_tray_button" href="#" onclick="return toggleable_tray(this.parentNode.parentNode,false,'{TITLE|}');">{TITLE`}</a>
            {+END}
        </h3>

        <div class="toggleable_tray">
            {+START,IF_EMPTY,{CONTENT}}
                <p class="nothing_here">{!NO_NEWS}</p>
            {+END}
            {+START,IF_NON_EMPTY,{CONTENT}}
                <div class="webstandards_checker_off">
                    {CONTENT}
                </div>
            {+END}
        </div>
    </section>

    {+START,IF,{$JS_ON}}
        <script>// <![CDATA[
            handle_tray_cookie_setting('{TITLE|}');
        //]]></script>
    {+END}
{+END}
{+START,IF,{TICKER}}
<!— stevyn test  —>
{+START,IF_NON_EMPTY,{CONTENT}}
<!— stevyn test  —>

    {$SET,side_news_id,{$RAND}}

    <section class="box box___block_side_rss"><div class="box_inner">
        {+START,IF_NON_EMPTY,{TITLE}}<h3>{TITLE`}</h3>{+END}

        {+START,IF_EMPTY,{CONTENT}}
            <p class="nothing_here">{!NO_NEWS}damn2</p>
        {+END}
        {+START,IF_NON_EMPTY,{CONTENT}}
            <div onmouseover="this.paused=true;" onmouseout="this.paused=false;" class="webstandards_checker_off wide_ticker" id="news_scroller{$GET%,side_news_id}">
                {CONTENT}
            </div>
        {+END}
    </div></section>

    <script>// <![CDATA[
        var scroll_speed=60;
        var scroller=document.getElementById('news_scroller{$GET%,side_news_id}');
        if (scroller)
        {
            scroller.paused=false;
            if (scroller.scrollHeight<300) scroll_speed=300; // Slow, as not much to scroll
            window.setTimeout(function() {
                window.setInterval(function() {
                    var scroller=document.getElementById('news_scroller{$GET%,side_news_id}');
                    if (scroller.paused) return;
                    if (scroller.scrollTop+find_height(scroller)>=scroller.scrollHeight-1)
                        scroller.scrollTop=0;
                    else
                        scroller.scrollTop++;
                } , scroll_speed);
            } ,2000);
        }
    //]]></script>
{+END}
<!— stevyn test  —>
{+END}
<!— stevyn test  —>

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

Manu, MVLipwig, amit.nigam, ManojSree, gabriel58

Forum statistics:
  • 1,298 topics, 5,830 posts, 7,065 members
  • Our newest member is raguragavan
Birthdays:
Back to Top