Skip to content Skip to navigation

2 Custom templates for the Stanford Modern theme

Topics: 

Let's get this out of the way now - VIEWS SUCKS - big time - when it comes to accessibility.

The reason why is because the assembled View has zero semantic structure - nada, zip, nothing - it's nothing but a bunch of divs. Sure, you can style the various field extracts using CSS to "look" like headers, lists, etc., but they aren't - they are and remain meaningless divs, and they fail accessibility in a huge way.

Fortunately, there might be a module for that here: http://drupal.org/project/semanticviews , or create your own custom templates, which is what I did for the Student Affairs website. those templates, along with a custom content type and a final view, outputs semantically structured code thta meets all accessibility requirements, and they are currently being used to good effect on sites such as haas.stanford.edu, registrar.stanford.edu and others.


Creating a Stanford News Entry Content type:

Screen Capture of the new fields
  • Creat a new content type called 'stanford_news_entry' - We've also named it the same thing 'Stanford News Entry
  • Description (feel free to modify as you see fit): "A Stanford News Article has an associated 'teaser' which is traditionally outputted to the front page of the site, with the headline being a hyperlink to the full news story. When creating a News Article, you will be prompted to determine whether it is a Feature Story, a Major Story, or a Minor Story. These classifications can be modified during the life-cycle of the news article, but can only be one of the three at any given time."

CCK new field entries:

Using CCK, you will need to create the following new field inputs:

Label Name Type Configuration
News Story Type field_story_type Text
  • Label: News Story Type
  • Field Type: text
  • Widget type: radio buttons/check boxes
  • Help text: The three choices are Feature Story, Major Story or Minor Story. By default the page view contains no more than 1 Feature Story (if more than one active story is classified as Featured, only the most recent will be displayed). The same default page view will display a maximum of 5 Major News Stories (again, if more than 5 exists it will be the 5 most recent), and a maximum of 10 Minor Stories.
  • Global Settings: Required - yes, Number of values: 1, Text processing: plain text, Allowed values list: Feature Story | Major Story | Minor Story
News Teaser field_story_teaser Text
  • Label: News Teaser
  • Field type: Text
  • Widget type: Text Area (mutliple rows) / Rows: 5 (you can modify this if you wish)
  • Help Text: "This is the News Story 'teaser' text used on the Front Page. Traditionally a repeat of the opening paragraph of your News Story, it can also be different text if so desired."
  • Global Settings: Required - yes, Number of values: 1, Text processing: filtered text (if you are using a WYSIWYG application)
Alternate location field_reference_url Text
  • Label: Alternate location
  • Field type: Text Field
  • Size of Text Field: 60
  • Help Text: "Where entry in Stanford News List should link if full story text field is empty"
  • Global Settings: Required - no, Number of values: 1, Text processing: Plain text
Feature Story Image field_feature_image Text
  • Label: Feature Story Image
  • Field type: Text Area (mutliple rows) / Rows: 5 (you can modify this if you wish)
  • Help Text: "This is for adding an image to news stories that will be Feature Stories. You should already have an image prepare for the story that is 145 pixels wide X 205 pixels high (sizing is important!). Feature Stories without an image supplied will default to the Stanford Seal in the required image area."
  • Global Settings: Required - no, Number of values: 1, Text processing: filtered text (if you are using a WYSIWYG application)
Major Story Image field_major_image Text
  • Label: Major Story Image
  • Field type: Text Area (mutliple rows) / Rows: 5 (you can modify this if you wish)
  • Help Text: "This is for adding an image to news stories that will be Major Stories. You should already have an image prepare for the story that is 139 pixels wide X 89 pixels high (sizing is important!). Major Stories without an image supplied will default to the Stanford Logo in the required image area."
  • Global Settings: Required - no, Number of values: 1, Text processing: filtered text (if you are using a WYSIWYG application)
Sorting Date field_sorting_date Date
  • Label: Sorting Date
  • Field type: Text Field with Date Popup Calendar
  • Default value: Now
  • Default value for To date: Same as From Date
  • Customize Default Value - Input format: mm/dd/yyyy - 12:34 pm
  • Help Text: "This is the highest priority date for the news article, and will be used for the primary sorting of all news articles. For example, an article that discusses Fourth of July activities would have a sorting date of July 4, regardless of when the article is written or released for publication. It is often the date of authoring (default), but can be modified as required."
  • Global Settings: Required - yes, Number of values: 1, To Date: Never, Granularity: Year+Month+Day+Hour, Default Display: Short Date, No Time, Time zone handling: Site's tiome zone
Publishing Dates field_publishing_dates Date
  • Label: Publishing Dates
  • Field type: Text Field with Date Popup Calendar
  • Default value: Now
  • Default value for To date: Relative
  • Customize Default Value - Input format: mm/dd/yyyy - 12:34 pm
  • Help Text: "By default, News Stories are published on the date of authoring, however they can be embargoed by changing the From date value. By default, News Stories expire 7 days after authoring, however this date can also be modified by changing the To date value."
  • Global Settings: Required - yes, Number of values: 1, To Date: Required, Granularity: Year+Month+Day+Hour, Default Display: Medium, Time zone handling: Site's tiome zone

View Import

IMPORTANT: Student Affairs currently uses Organic Groups and the Workflow module to manage our sites. This Exported View includes settings for these modules, and may need to be modified at the individual site level. You will likely also want this module: http://drupal.org/project/import_export_tool to quickly import this view. (Don't want to do that? Try contacting John Foliot for alternatives.)

$view = new view;
$view->name = 'stanford_news_list';
$view->description = 'Homepage News Content';
$view->tag = 'og ';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'field_feature_image_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 1,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_feature_image_value',
    'table' => 'node_data_field_feature_image',
    'field' => 'field_feature_image_value',
    'relationship' => 'none',
  ),
  'field_major_image_value' => array(
    'label' => 'Major Story Image',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_major_image_value',
    'table' => 'node_data_field_major_image',
    'field' => 'field_major_image_value',
    'relationship' => 'none',
  ),
  'field_story_teaser_value' => array(
    'label' => 'News Teaser',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_story_teaser_value',
    'table' => 'node_data_field_story_teaser',
    'field' => 'field_story_teaser_value',
    'relationship' => 'none',
  ),
  'field_sorting_date_value' => array(
    'label' => 'Sorting Date',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 1,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => TRUE,
    ),
    'repeat' => array(
      'show_repeat_rule' => '',
    ),
    'fromto' => array(
      'fromto' => 'both',
    ),
    'exclude' => 0,
    'id' => 'field_sorting_date_value',
    'table' => 'node_data_field_sorting_date',
    'field' => 'field_sorting_date_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'field_story_type_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_story_type_value',
    'table' => 'node_data_field_story_type',
    'field' => 'field_story_type_value',
    'relationship' => 'none',
  ),
  'field_sorting_date_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_sorting_date_value',
    'table' => 'node_data_field_sorting_date',
    'field' => 'field_sorting_date_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'group_nid' => array(
    'default_action' => 'not found',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%1',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'og_group_types',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'group_nid',
    'table' => 'og_ancestry',
    'field' => 'group_nid',
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'basic_page' => 0,
      'book' => 0,
      'change_log_entry' => 0,
      'fellowship' => 0,
      'page' => 0,
      'registrar_basic_page' => 0,
      'stanford_news_entry' => 0,
      'stanford_topic_entry' => 0,
      'unit' => 0,
      'webmaster' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '3' => 0,
      '5' => 0,
      '6' => 0,
      '8' => 0,
      '9' => 0,
      '7' => 0,
      '12' => 0,
      '17' => 0,
      '18' => 0,
      '15' => 0,
      '16' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_is_member' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'status_extra' => array(
    'id' => 'status_extra',
    'table' => 'node',
    'field' => 'status_extra',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'stanford_news_entry' => 'stanford_news_entry',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
  'sid' => array(
    'operator' => 'in',
    'value' => array(
      '3' => '3',
      '7' => '7',
      '8' => '8',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'sid',
    'table' => 'workflow_node',
    'field' => 'sid',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'What\'s New');
$handler->override_option('header', '<h2 class="newsheading">What\'s New</h2>');
$handler->override_option('header_format', '1');
$handler->override_option('header_empty', 0);
$handler->override_option('use_pager', '1');
$handler->override_option('distinct', 1);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'teaser' => 0,
  'links' => 1,
  'comments' => 0,
));
$handler = $view->new_display('page', 'Main News aggregation', 'page_1');
$handler->override_option('path', 'main_news_agg');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));

I need to more fully document the CCK fields and View instructions, but for this posting, I am providing the templates - check back in a bit and I'll have more done.

/>