Showing posts with label drupal. Show all posts
Showing posts with label drupal. Show all posts

December 16, 2011

Drupal-in-Brief: Views and Blocks

Working with Views fields display


As an example we'll shorten the Research Interests text to Research in the People/Faculty view.

Go to the Views list page and click edit for the Faculty view:
https://yourSite.sfsu.edu/admin/build/views (View all current sites)



Click on the Page display link in the left-hand menu, then click the Preview button to see a Live Preview of the current view.



We need to reconfigure the Fields Page display settings. Scroll back up, and take a look at the Fields box for Page display.



The fields listed are specific to the People subpage content type and are dependent upon the Filters settings. Just keep that in mind if you start getting blank views or fields.

If you click on each of the fields listed, starting from the top, you'll notice that for almost all of the fields, Exclude from display is checked. The exception is the bottom-most field, which contains the output display code.

Click on the last field, Content:Job title, to see the rewrite pattern used for the Faculty view.




This is the code:

<div class="brief">

[field_thumbnail_fid]
[title]
<p>[field_title_value]</p>
<p><strong>Research Interests:</strong> [field_keywords_value]</p>
</div>


The text in square brackets are placeholder variables, or field tokens that can be used to display data in a view. The HTML code is based on the standard .brief formatting style provided by the SF State webtemplate stylesheet.

This is the actual HTML code generated by the view:


<div class="brief">
<img class="imagefield imagefield-field_thumbnail" width="90" height="90" alt="Generic Profile Image" src="https://wcmdemo.sfsu.edu/art/sites/wcmdemo.sfsu.edu.art/files/images/th/uid/90x90_profile.png?1324035407">
<h2><a href="/art/faculty/john-q-public">John Q. Public</a></h2>
<p>Assistant Professor</p>
<p><strong>Research Interests:</strong> Art History, Asian Art History</p>
</div>


For this example, we will just shorten the Research text.


<div class="brief">
[field_thumbnail_fid]
[title]
<p>[field_title_value]</p>
<p><strong>Research:</strong> [field_keywords_value]</p>
</div>


Click the Update button, and you should your changes reflected in the Live Preview section at the bottom of the page. Click the Save button to make your changes permanent.

Notes

When making changes, take care when using the override and use default options when making changes. Override is generally a safer option if you have multiple displays within a single view.

Basic Settings:


  • Change between unformatted, lists and tables.
  • Items to display
  • You also provide default text for Header, Footer, empty text.



Relationships and Arguments:

Provides advanced configuration. Learn more by picking up a good Drupal book: https://sites.sfsu.edu/drupal/free-drupal-books-readable-online-library

Fields:

Very flexible. Dependent upon fields in content types.

Sort criteria:

Lots of sorting options like alpha, descending, ascending, etc.

Filters:

Determines what content nodes will show up. Can be broad (all published) or specific (news content published in the last month by a specific author).

Working with blocks


There are two types of blocks: 1) static blocks, and blocks dynamically-generated by views. Blocks are basically content snippets configured to appear within regions of a site (left sidebar, main, right sidebar, etc.) with additional visibility options for specific pages or users.

Static blocks


  1. Login and go to the Block list for your site:
    https://youSite/admin/build/block/list
  2. Click Add block.
  3. Provide a Block description, title (optional depending on the format), and Block body content.
  4. Click Save Block.


You’ll end up back at the Blocks listing. Use your browser’s search or scroll down to the Disabled section to find the block you just created.

Change the Region settings from to Right Sidebar and click Save. Your block will move up to the list of blocks in the Right Sidebar region and will also now appear on the live site.

By default, your new block will show up on every single page of your site. If you want your block to only appear on a specific page, you can configure the visibility settings by user, role or page.

To configure the page specific visibility settings, go back to the block list and click on the configure link. Click the Show on only the listed pages radio button, then enter the path to the page the block where the block should be visible (e.g. people). Check the instructions provided on the page for more information.

To unpublish a block, change the region settings back to none. Only static blocks will have a delete link. Dynamic blocks generated by views must be removed from the view itself.


Dynamic Blocks


Views generated blocks are beyond what be explained here (check http://drupal.org for tutorials). As a building block, the link below contains code for a “promote to frontpage” events block.

Code for Promoted Events Views block


(Instructions: Download and copy and paste the code into the Views Import field.)


For visual reference, the code is posted below.

===


$view = new view;
$view->name = 'Announcement';
$view->description = 'Display announcements as a portlet';
$view->tag = 'Announcements';
$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', 'Announcements', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 1,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '
',
      'suffix' => '


',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'field_date_value' => array(
    'id' => 'field_date_value',
    'table' => 'node_data_field_date',
    'field' => 'field_date_value',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'announcement' => 'announcement',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'status_extra' => array(
    'operator' => '=',
    'value' => '',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status_extra',
    'table' => 'node',
    'field' => 'status_extra',
    'relationship' => 'none',
  ),
  'date_filter' => array(
    'operator' => '<=',
    'value' => array(
      'value' => NULL,
      'min' => NULL,
      'max' => NULL,
      'default_date' => 'now',
      'default_to_date' => 'now',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_duration.field_duration_value' => 'node_data_field_duration.field_duration_value',
    ),
    'date_method' => 'AND',
    'granularity' => 'day',
    'form_type' => 'date_popup',
    'default_date' => 'now',
    'default_to_date' => 'now',
    'year_range' => '-3:+3',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
  'date_filter_1' => array(
    'operator' => '>=',
    'value' => array(
      'value' => NULL,
      'min' => NULL,
      'max' => NULL,
      'default_date' => 'now',
      'default_to_date' => 'now',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_duration.field_duration_value2' => 'node_data_field_duration.field_duration_value2',
    ),
    'date_method' => 'AND',
    'granularity' => 'day',
    'form_type' => 'date_popup',
    'default_date' => 'now',
    'default_to_date' => 'now',
    'year_range' => '-3:+3',
    'id' => 'date_filter_1',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'Announcements');
$handler->override_option('items_per_page', 4);
$handler->override_option('use_pager', '1');
$handler->override_option('use_more', 0);
$handler->override_option('use_more_always', 0);
$handler->override_option('style_options', NULL);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'relationship' => 'none',
  'build_mode' => 'full',
  'links' => 0,
  'comments' => 0,
));
$handler = $view->new_display('block', 'Block', 'block_2');
$handler->override_option('fields', array(
  'field_thumbnail_fid' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 1,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'image_plain',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 1,
    'id' => 'field_thumbnail_fid',
    'table' => 'node_data_field_thumbnail',
    'field' => 'field_thumbnail_fid',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
  'field_date_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => '[field_date_value]:',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 1,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'event',
    'multiple' => array(
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => 0,
    ),
    'repeat' => array(
      'show_repeat_rule' => 'hide',
    ),
    'fromto' => array(
      'fromto' => 'both',
    ),
    'exclude' => 1,
    'id' => 'field_date_value',
    'table' => 'node_data_field_date',
    'field' => 'field_date_value',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => '[field_date_value] [title]',
      'make_link' => 1,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => ' ',
      'suffix' => '  ',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 1,
    'exclude' => 1,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Use default',
    ),
  ),
  'field_summary_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 1,
    'id' => 'field_summary_value',
    'table' => 'node_data_field_summary',
    'field' => 'field_summary_value',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
  'field_notes_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 1,
    'id' => 'field_notes_value',
    'table' => 'node_data_field_notes',
    'field' => 'field_notes_value',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
  'field_announcement_value' => array(
    'label' => 'Announcement',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 1,
    'id' => 'field_announcement_value',
    'table' => 'node_data_field_announcement',
    'field' => 'field_announcement_value',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
  'field_introduction_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => '<div class="brief">
[field_thumbnail_fid]
<h2>[title]</h2>
<!--[field_summary_value] [field_notes_value] [field_introduction_value]-->
</div>',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_introduction_value',
    'table' => 'node_data_field_introduction',
    'field' => 'field_introduction_value',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'not in',
    'value' => array(
      'feed' => 'feed',
      'feed_item' => 'feed_item',
      'exhibition_listing' => 'exhibition_listing',
      'feed_delicious' => 'feed_delicious',
      'webform' => 'webform',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Use default',
    ),
  ),
  'promote' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'promote',
    'table' => 'node',
    'field' => 'promote',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('items_per_page', 3);
$handler->override_option('use_pager', '0');
$handler->override_option('row_plugin', 'semanticviews_fields');
$handler->override_option('row_options', array(
  'semantic_html' => array(
    'title' => array(
      'element_type' => 'div',
      'class' => '',
    ),
    'created' => array(
      'element_type' => 'div',
      'class' => '',
    ),
    'teaser' => array(
      'element_type' => 'div',
      'class' => '',
    ),
  ),
  'skip_blank' => 1,
));
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);



===

May 23, 2011

D7 theme project: Accessibility + Starter Theme links

Drupal theming resources collected for the SF State D7 Theme working group:

April 18, 2011

RSVP for SF State Web Content Management rollout sessions

Good news! After more than 2 years of planning and preparation, the SF State Department of Information Technologies (DoIT) has announced that the campus-wide rollout of the SF State Web Content Management and hosting solution will begin in May.

September 22, 2009

Drupal How-to: Post a Video Podcast

Create a video podcast from content hosted on the Internet Archive using the Drupal CMS.

August 24, 2009

Updates to the faculty and directory website areas

Faculty and Staff Directory
Quick Summary:
  1. Added First (First name) field.
  2. Added Area of Expertise, Advising Duties, Teaching Area fields. These fields replace the Emphasis column heading in the Google Doc
  3. Position Category. Default terms are Faculty, Lecturers, Staff. Used by the PathAuto module to build URL alias (e.g. /staff/419/bren-ahearn)
  4. Change Faculty menu to Faculty and Staff. Added the following submenu items: Faculty Advisers, Lecturers, Staff.

October 29, 2008

Drupal: Page headers

Page headers (Imageboxes) on department sites require three parts:
  1. A background image.
  2. Brief, descriptive heading and a link to an edited photoset or set of tagged photos on Flickr.
  3. A list of pages where the Imagebox should or shouldn't appear.

October 22, 2008

College of Creative Arts Scholarships Feed

Web pages from the scholarships area of the College of Creative Arts website has been added to all the departments sites via an automated RSS feed.

September 17, 2008

Add Flickr photos to a Drupal node

Problem

You would like to add or replace a photo (image) on a content page in Drupal.

Purpose

The purpose of this guide is to demonstrate how to add an image to a content page in Drupal using HTML code automatically generated by Flickr.

Disqus for Passing the Word