User login

If a direct call to a view isn't working... check that you didn't break the view quite independently in theming it

Or, the more custom work you do, the more ways broken things can be your fault.

views_build_view and theming views

It turns out that the reason view was not working - not showing up at all - when call through views_build_view had nothing to do with the custom call. The view isn't showing up when displayed as a list, period.

I removed two fields -- CCK fields that I don't think apply to video module -- but it still isn't working, yet.

Ahh. I had views template exported and modified in template.php that was screwing things up. It only affects list themes. Here's my broken version:

/**
* views template to output a view.
* Agaric modified to not theme as a list (at the end)
* All the real action is in views-list-Video_Features.tpl.php
* This code was generated by the views theming wizard
* Date: Tue, 2007-06-12 20:44
* View: Video_Features
*
* This function goes in your template.php file
*/
function phptemplate_views_view_list_Video_Features($view, $nodes, $type) {
  $fields = _views_get_fields();
  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $items[] = _phptemplate_callback('views-list-Video_Features', $vars);
  }
/**
  * Return a themed set of tabs.  Modeled loosely on theme_item_list() it produces the code needed for tabpane.js to do its stuff.
  *
  * For more, see sites/coanews.org/modules/agaricdev/coamod
  */
  // Replaces call to theme_item_list
  if (!empty($items)) {
    $output = '<div class="video-features">';
    foreach ($items as $item) {
      $output .= ''. $item .'';
    }
  }
}

/**
* views template to output a view.
* This code was generated by the views theming wizard
* Date: Mon, 2007-08-06 06:49
* View: Video_Features
*
* This function goes in your template.php file
*/
function phptemplate_views_view_list_Video_Features($view, $nodes, $type) {
  $fields = _views_get_fields();

  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $items[] = _phptemplate_callback('views-list-Video_Features', $vars);
  }
  if ($items) {
    return theme('item_list', $items);
  }
}

&lt;?php
/**
* views template to output one 'row' of a view.
* This code was generated by the views theming wizard
* Date: Mon, 2007-08-06 06:49
* View: Video_Features
*
* Variables available:
* $view -- the entire view object. Important parts of this object are
*   Video_Features, .
* $view_type -- The type of the view. Probably 'page' or 'block' but could
*   also be 'embed' or other string passed in from a custom view creator.
* $node -- the raw data. This is not a real node object, but will contain
*   the nid as well as other support fields that might be necessary.
* $count -- the current row in the view (not TOTAL but for this page) starting
*   from 0.
* $stripe -- 'odd' or 'even', alternating.
* $title -- Display the title of the node.
* $title_label -- The assigned label for $title
* $created -- Display the post time of the node. The option field may be used to specify the custom date format as it's required by the date() function or if "as time ago" has been chosen to customize the granularity of the time interval.
* $created_label -- The assigned label for $created
* $nid -- Display the NID of a node.
* $nid_label -- The assigned label for $nid
* $type -- The Node Type field will display the type of a node (for example, 'blog entry', 'forum post', 'story', etc)
* $type_label -- The assigned label for $type
* $link -- This will create a link to the node; fill the option field with the text for the link. If you want titles that link to the node, use Node: Title instead.
* $link_label -- The assigned label for $link
* $field_source_url --
* $field_source_url_label -- The assigned label for $field_source_url
* $field_lede_pic_fid --
* $field_lede_pic_fid_label -- The assigned label for $field_lede_pic_fid
*
* This function goes in your views-list-Video_Features.tpl.php file
*/
  ?&gt;
&lt;div class=&quot;view-label view-field-title&quot;&gt;
  &lt;?php print $title_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-title&quot;&gt;
  &lt;?php print $title?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-created&quot;&gt;
  &lt;?php print $created_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-created&quot;&gt;
  &lt;?php print $created?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-nid&quot;&gt;
  &lt;?php print $nid_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-nid&quot;&gt;
  &lt;?php print $nid?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-type&quot;&gt;
  &lt;?php print $type_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-type&quot;&gt;
  &lt;?php print $type?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-link&quot;&gt;
  &lt;?php print $link_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-link&quot;&gt;
  &lt;?php print $link?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-field-source-url&quot;&gt;
  &lt;?php print $field_source_url_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-field-source-url&quot;&gt;
  &lt;?php print $field_source_url?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-field-lede-pic-fid&quot;&gt;
  &lt;?php print $field_lede_pic_fid_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-field-lede-pic-fid&quot;&gt;
  &lt;?php print $field_lede_pic_fid?&gt;
&lt;/div&gt;

Or, the more custom work you do, the more ways broken things can be your fault.

views_build_view and theming views

It turns out that the reason view was not working - not showing up at all - when call through views_build_view had nothing to do with the custom call. The view isn't showing up when displayed as a list, period.

I removed two fields -- CCK fields that I don't think apply to video module -- but it still isn't working, yet.

Ahh. I had views template exported and modified in template.php that was screwing things up. It only affects list themes. Here's my broken version:

/**
* views template to output a view.
* Agaric modified to not theme as a list (at the end)
* All the real action is in views-list-Video_Features.tpl.php
* This code was generated by the views theming wizard
* Date: Tue, 2007-06-12 20:44
* View: Video_Features
*
* This function goes in your template.php file
*/
function phptemplate_views_view_list_Video_Features($view, $nodes, $type) {
  $fields = _views_get_fields();
  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $items[] = _phptemplate_callback('views-list-Video_Features', $vars);
  }
/**
  * Return a themed set of tabs.  Modeled loosely on theme_item_list() it produces the code needed for tabpane.js to do its stuff.
  *
  * For more, see sites/coanews.org/modules/agaricdev/coamod
  */
  // Replaces call to theme_item_list
  if (!empty($items)) {
    $output = '<div class="video-features">';
    foreach ($items as $item) {
      $output .= ''. $item .'';
    }
  }
}

/**
* views template to output a view.
* This code was generated by the views theming wizard
* Date: Mon, 2007-08-06 06:49
* View: Video_Features
*
* This function goes in your template.php file
*/
function phptemplate_views_view_list_Video_Features($view, $nodes, $type) {
  $fields = _views_get_fields();

  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $items[] = _phptemplate_callback('views-list-Video_Features', $vars);
  }
  if ($items) {
    return theme('item_list', $items);
  }
}

&lt;?php
/**
* views template to output one 'row' of a view.
* This code was generated by the views theming wizard
* Date: Mon, 2007-08-06 06:49
* View: Video_Features
*
* Variables available:
* $view -- the entire view object. Important parts of this object are
*   Video_Features, .
* $view_type -- The type of the view. Probably 'page' or 'block' but could
*   also be 'embed' or other string passed in from a custom view creator.
* $node -- the raw data. This is not a real node object, but will contain
*   the nid as well as other support fields that might be necessary.
* $count -- the current row in the view (not TOTAL but for this page) starting
*   from 0.
* $stripe -- 'odd' or 'even', alternating.
* $title -- Display the title of the node.
* $title_label -- The assigned label for $title
* $created -- Display the post time of the node. The option field may be used to specify the custom date format as it's required by the date() function or if "as time ago" has been chosen to customize the granularity of the time interval.
* $created_label -- The assigned label for $created
* $nid -- Display the NID of a node.
* $nid_label -- The assigned label for $nid
* $type -- The Node Type field will display the type of a node (for example, 'blog entry', 'forum post', 'story', etc)
* $type_label -- The assigned label for $type
* $link -- This will create a link to the node; fill the option field with the text for the link. If you want titles that link to the node, use Node: Title instead.
* $link_label -- The assigned label for $link
* $field_source_url --
* $field_source_url_label -- The assigned label for $field_source_url
* $field_lede_pic_fid --
* $field_lede_pic_fid_label -- The assigned label for $field_lede_pic_fid
*
* This function goes in your views-list-Video_Features.tpl.php file
*/
  ?&gt;
&lt;div class=&quot;view-label view-field-title&quot;&gt;
  &lt;?php print $title_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-title&quot;&gt;
  &lt;?php print $title?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-created&quot;&gt;
  &lt;?php print $created_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-created&quot;&gt;
  &lt;?php print $created?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-nid&quot;&gt;
  &lt;?php print $nid_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-nid&quot;&gt;
  &lt;?php print $nid?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-type&quot;&gt;
  &lt;?php print $type_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-type&quot;&gt;
  &lt;?php print $type?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-link&quot;&gt;
  &lt;?php print $link_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-link&quot;&gt;
  &lt;?php print $link?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-field-source-url&quot;&gt;
  &lt;?php print $field_source_url_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-field-source-url&quot;&gt;
  &lt;?php print $field_source_url?&gt;
&lt;/div&gt;

&lt;div class=&quot;view-label view-field-field-lede-pic-fid&quot;&gt;
  &lt;?php print $field_lede_pic_fid_label ?&gt;
&lt;/div&gt;
&lt;div class=&quot;view-field view-data-field-lede-pic-fid&quot;&gt;
  &lt;?php print $field_lede_pic_fid?&gt;
&lt;/div&gt;

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.