Ticker Tape News for Drupal 7

The "marquee" element was originally designed by Microsoft for early versions of Internet Explorer. Rather like Netscape's "blink" element, it is usually thoroughly unloved by web developers, for being proprietory, non-standard, causing usability problems, and is distracting to other content. It is considered deprecated by the W3C and not advised for use in any HTML documents.

Jakob Nielsen, as far back as 1996 declared that scrolling and blinking text is one of the top-ten mistakes in web design, and there's certainly no disagreement from this designer who put claims that accessible content is the only thing that matters. But others disagree - for a while the BBC had a ticker-style news feed.

So assume, for the sake of humour if nothing else, that a deliberately distracting marquee style news feed is actually desired. How does one implement this in Drupal?

Well, firstly you don't use the marquee tag. Instead download and extract (e.g., /usr/share/drupal7/sites/all/modules). the Views Ticker module. As the name suggests, this requires Views, and also Chaos Tools to be already implemented.

Enable the module and create a content type (admin/structure/types/add) for the ticker. Give it a name like "News Ticker" (machine name news_ticker). Turn off "published to front page" and (optionally) comments. Save the content type.

Now create a View called news_ticker (admin/structure/views/view/). On the Page display you'll want to give it an appopriate title (e.g., Latest News), set the Format to Views Ticker, using whichever ticker style you want (vertical, horizontal, fade, BBC-style etc) and speed. Select Fields to show; linked with title is a good choice. The filter criteria is published and using the News Ticker content type. Use the Post date sort criteria. Add a block page, and - this is important - turn off the pager options and set to 0 to display. In our particular case we wanted to include the Events node references as well.

An example of the View is as follows:


$view = new view;
$view->name = 'news_ticker';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'News Ticker';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Latest News';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '0';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'views_ticker';
$handler->display->display_options['style_options']['liScroll_Options'] = array(
'liScroll_speed' => '0.07',
'liScroll_direction' => 'left',
'liScroll_mouseover' => 1,
'liScroll_delay' => 0,
'liScroll_bounce' => 0,
);
$handler->display->display_options['style_options']['vTicker_Options'] = array(
'vTicker_mouseover' => 0,
'vTicker_speed' => '500',
'vTicker_pause' => '1000',
'vTicker_items' => '5',
'vTicker_direction' => 'up',
);
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['hide_empty'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 0;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'event' => 'event',
'news_ticker' => 'news_ticker',
);
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'news-ticker';
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block_1');
$translatables['news_ticker'] = array(
t('Master'),
t('Latest News'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Page'),
t('Block'),
);

Go to the block structures (admin/structure/block and add it to News Ticker block to the section of the site you consider most appropriate. You may very well want to include a restriction on the pages that it is viewed on; in this particular case, the front page only. Add the following well-known PHP function.


if (drupal_is_front_page()) {
return TRUE;
}
?>

There, you're done! And may God have mercy on your soul.

Comments

Note to change what you have on your news feed you will need to (a) unpublish the item or (b) change the content type.

A slight bug exists; if you have a title with a slash in it (e.g., New Linux/HPC Courses) the title will not display on the ticker. The quick and easy workaround is to remove the slash (e.g., New Linux and HPC Courses). My first guess is that the View doesn't escape meta-characters from the title displays.