Advertisement:

Author Topic: News/Newsticker  (Read 1436 times)

Offline Monday11

  • Semi-Newbie
  • *
  • Posts: 17
News/Newsticker
« on: August 30, 2018, 02:22:21 PM »
Hello, I have been searching for a news ticker that I can add to my site and hide the news in the top right corner.  Is this possible and if so what do I need to do?  Thanks.

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,526
  • Gender: Male
    • SychO9 on GitHub
    • SychO

Imazighen

Offline Monday11

  • Semi-Newbie
  • *
  • Posts: 17
Re: News/Newsticker
« Reply #2 on: August 30, 2018, 03:40:36 PM »
I apologize I'm lost.  I downloaded jquery.marquee.min.js, do I add it to the cpanel file manager if so where?

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,526
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: News/Newsticker
« Reply #3 on: August 30, 2018, 03:57:28 PM »
Although I linked to @Antes's solution as it's better and more detailed,

put the file in "Themes/default/scripts" located in your forum's directory, after that

add this code before the </head> tag in your index.template.php

If you have jQuery already loaded in your forum remove the first line :
Code: [Select]
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="', $settings['default_theme_url'], '/scripts/jquery.marquee.min.js?fin20"></script>

in index.template.php
Look for
Code: [Select]
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<h2>', $txt['news'], ': </h2>
<p>', $context['random_news_line'], '</p>';

echo '
</div>
</div>
<br class="clear" />';
Change it to
Code: [Select]
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news'])) {
echo '
<h2>', $txt['news'], ': </h2>
<div class="news_marquee">
<div class="marquee">';

foreach ($context['news_lines'] as $news) {
echo '<span style="margin-right: 1em">', $news, '</span>';
}

echo'
</div>
</div>
<script>
$(\'.marquee\').marquee({
// speed in milliseconds of the marquee
duration: 14000
});
</script>
<style>.marquee {
  width: 100%; /* Edit this to your preference */
  overflow: hidden;
}</style>';
}


Imazighen

Offline Monday11

  • Semi-Newbie
  • *
  • Posts: 17
Re: News/Newsticker
« Reply #4 on: August 30, 2018, 04:37:50 PM »
I'm still not finding where the code goes.  I went to index.template.php.

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,526
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: News/Newsticker
« Reply #5 on: August 30, 2018, 04:49:24 PM »
Look for
Code: [Select]
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<h2>', $txt['news'], ': </h2>
<p>', $context['random_news_line'], '</p>';

echo '
</div>
</div>
<br class="clear" />';
Change it to
Code: [Select]
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news'])) {
echo '
<h2>', $txt['news'], ': </h2>
<div class="news_marquee">
<div class="marquee">';

foreach ($context['news_lines'] as $news) {
echo '<span style="margin-right: 1em">', $news, '</span>';
}

echo'
</div>
</div>
<script>
$(\'.marquee\').marquee({
// speed in milliseconds of the marquee
duration: 14000
});
</script>
<style>.marquee {
  width: 100%; /* Edit this to your preference */
  overflow: hidden;
}</style>';
}

Did you look for the code mentioned ? did you make a search ?

Imazighen

Offline Monday11

  • Semi-Newbie
  • *
  • Posts: 17
Re: News/Newsticker
« Reply #6 on: August 30, 2018, 04:58:22 PM »
I did.

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,526
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: News/Newsticker
« Reply #7 on: August 30, 2018, 05:04:10 PM »
In that case, you must not be using the default theme
if you are using the default theme, than you have a mod that changed the code

Imazighen

Offline Monday11

  • Semi-Newbie
  • *
  • Posts: 17
Re: News/Newsticker
« Reply #8 on: August 30, 2018, 05:10:27 PM »
Does it have to be the default theme?  Would it not work with another theme?