When I enable the default view taxonomy_term any fields that I have added to the vocabulary disappear and I get the following error:

Notice: Trying to get property of non-object in taxonomy_term_edit_access() (line 373 of /../modules/taxonomy/taxonomy.module).

Not sure what's happening here.

CommentFileSizeAuthor
#10 taxo-view1.jpg303.61 KBcnolle
#10 taxo-view2.jpg158.07 KBcnolle

Comments

slashrsm’s picture

Which version of Views do you use? CVS HEAD? Which version of D7 core do you use?

cnolle’s picture

This happens using Views latest dev and Drupal 7 RC1

Ryan Martin’s picture

Can replicate with RC1 views 7.x-3.x-dev

Jarode’s picture

I experience exactly the same issue when I activate the default view taxonomy_term. It's highly reproductible.
Drupal 7 RC-1
Views 7.x-3.x-dev

slashrsm’s picture

Assigned: Unassigned » dawehner
dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Can you describe step by step how to reproduce the problem?

cnolle’s picture

Add some fields to your vocabulary, my site has one image field and two text fields. Without the taxonomy/term view enabled the fields show up when you view the taxonomy/term page. However, if you enable the taxonomy/term view the fields disappear.

I get the following error as well:
Notice: Trying to get property of non-object in taxonomy_term_edit_access() (line 373 of /modules/taxonomy/taxonomy.module).

dawehner’s picture

Did you changed your taxonom/term view?

The view has row style node, so the terms are listed as links. So what's the reason the additional field to the term should be displayed.

Some screenshots might help. I can't reproduce it.

cnolle’s picture

I haven't changed the default taxonomy/view - I just enabled the default view.

Please see attached screenshots. This is using the lates dev of D7 and View 3. No other modules is installed.

To reproduce I did the following:

1. I created a new vocabulary called organizations.
2. In this new vocubulary I created two fields (both Long text and summary).
3. I created a new term in the vocabulary and filled the two text fiels with lorem ipsum.
4. Created a new field in the article content type which would reference this vocabulary.
5. Create a new article assign it to the term I just created.

If you view the taxonomy/term page without the view enabled all is well. The two fields appear at the top of the taxonomy/term page with a teaser of the article appearing below.

If you enabled the default taxonomy/term view the fields disappear and all that remains is the article teaser.

cnolle’s picture

StatusFileSize
new158.07 KB
new303.61 KB

Here's some annotated screenshots.

dawehner’s picture

Status: Postponed (maintainer needs more info) » Fixed

aaaaaaaaaaaaaaah.

But this will be a bit disapointing.

Views is a tool to build lists of items, here nodes.
So there will be no automatically build lists of items AND load the term and show the term.
But since views 3.x, it's possible to write a area handler which prints the stuff you want.
Maybe it would be even possible to be included in views: A area handler which renders a single entity in the header, based on manual settings or based on argument. You could create a new issue for this.

cnolle’s picture

I was thinking something along those lines. Logically you should somehow be able to add the term fields to the header view - or footer for that matter (like you can at the moment with global text area). That would make sense and give everyone granular control over where those term fields appear in taxonomy/term view.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tkcent’s picture

You can use hook_view_pre_render() in your template.php file to alter many parts of the view including title, header or footer as shown below.

Example:

function hook_views_pre_render(&$view) {
  // Optionally check display
  if($view->current_display == 'page') {
    // Use machine name for view.  In this case it is company_view
    // which is an example view for a Company that has the additional
    // text field of City and a taxonomy reference for State/Province.
    if($view->name == 'company_view') {
      // Get the taxonomy term id
      $tid = $view->args[0];
      // Verify its valid and load the taxonomy object
      if($tid && $term = taxonomy_term_load($tid)) {
        // Get the vocabulary id
        $vid = $term->vid;
        // Get the taxonomy id of the state/province.
        // We will get the term name later.
        $stateprov_tid = $term->field_state_province['und']['0']['tid'];
        // Get the city name, which is an extra field we added
        $city = $term->field_city['und']['0']['value']
        // Verify vid is valid and load vocabulary object
        if ($vid && $vocab = taxonomy_vocabulary_load($vid) ) {
          // Modify term name to include the vocabulary
          // name and update view title
          $term->name = $vocab->name . ": " . $term->name;
          $view->set_title($term->name);
        }
        // Optionally alter view header to include other fields,
        // in this example a city and state/province.
        if ($term->vocabulary_machine_name == 'company') {
          // Verify we have a valid state/province term
          // and load the object.
          if ($stateprov_tid && $stateprov_term = taxonomy_term_load($stateprov_tid)) {
            // Set the header value to City, State/Province.
            $header = $city . ", " . $stateprov_term->name;
            // Set the options for the view header
            $options = array(
              'id' => 'area',
              'table' => 'views',
              'field' => 'area',
              'empty' => FALSE,
              'content' => $header,
              'format' => 2,
              'tokenize' => 0,
              );
            // Update the view with the new header
            $view->set_item('default', 'header', 'area', $options); 
          }
        }
      }
    }
  }
}