News/Newsticker

Started by Monday11, August 30, 2018, 02:22:21 PM

Previous topic - Next topic

Monday11

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.

SychO

Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Monday11

I apologize I'm lost.  I downloaded jquery.marquee.min.js, do I add it to the cpanel file manager if so where?

SychO

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 :
<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 // 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 // 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>';
}


Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Monday11

I'm still not finding where the code goes.  I went to index.template.php.

SychO

Quote from: SychO on August 30, 2018, 03:57:28 PM
Look for // 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 // 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 ?
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Monday11


SychO

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
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Monday11

Does it have to be the default theme?  Would it not work with another theme?

Advertisement: