Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Topic started by: Monday11 on August 30, 2018, 02:22:21 PM

Title: News/Newsticker
Post by: Monday11 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.
Title: Re: News/Newsticker
Post by: SychO on August 30, 2018, 02:26:21 PM
https://www.simplemachines.org/community/index.php?topic=561686.msg3986178#msg3986178
Title: Re: News/Newsticker
Post by: Monday11 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?
Title: Re: News/Newsticker
Post by: SychO 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 :
<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>';
}


Title: Re: News/Newsticker
Post by: Monday11 on August 30, 2018, 04:37:50 PM
I'm still not finding where the code goes.  I went to index.template.php.
Title: Re: News/Newsticker
Post by: SychO on August 30, 2018, 04:49:24 PM
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 ?
Title: Re: News/Newsticker
Post by: Monday11 on August 30, 2018, 04:58:22 PM
I did.
Title: Re: News/Newsticker
Post by: SychO 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
Title: Re: News/Newsticker
Post by: Monday11 on August 30, 2018, 05:10:27 PM
Does it have to be the default theme?  Would it not work with another theme?