I have a page views with selected fields to display as a table style format.
One of the field taxonomy id which I exclude from the display, (capture.png) this field will be used for views theming used for jquery stuff.

I use "Style output" suggested template, views-view-table--contact-us--page.tpl.php, where contact-us is my views name.

In the template file I did
dpm($rows) But I cannot find the taxonomy id.

From the description of 'exclude from display',
"Check this box to not display this field, but still load it in the view. Use this option to not show a grouping field in each record, or when doing advanced theming."
It said that is still load in the view but not display it.

Should I misunderstood something ?

CommentFileSizeAuthor
#1 Capture.PNG14 KBadrianmak
Capture.PNG19.22 KBadrianmak

Comments

adrianmak’s picture

StatusFileSize
new14 KB

It'll look like this

temp’s picture

Find solution? If yes, how?

OnkelTem’s picture

Any solution?

adrianmak’s picture

I modifiied the views-table template.

Checking of is this field is a tid field than put the value to a class and then don't output the tid field to table

OnkelTem’s picture

I don't get it.
If I exclude a field, its not in $rows anymore.
Also, its not in $view->result array!

Table output style is missing -fields template, instead, it is using:

-field
--table
---view

hierarchy. At any stage I can't access my fields - i.e. raw result.

p.s. I also tried to inject some vars which are probably missed in template, but in template_preprocess_views_view_table I don't get anything new.

adrianmak’s picture

Sorry, I missed one point.

The tid field is not excluded in views and combine with my method on my last reply

this is my modified views-table template

<table class="<?php print $class; ?>">
  <?php if (!empty($title)) : ?>
    <caption><?php print $title; ?></caption>
  <?php endif; ?>
  <thead>
    <tr>
  
      <?php foreach ($header as $field => $label): ?>
  <?php if ($field!="tid") { ?>
        <th class="views-field views-field-<?php print $fields[$field]; ?>">
          <?php print $label; ?>
        </th>
<?php } ?>
      <?php endforeach; ?>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($rows as $count => $row): ?>
    
      <tr class="<?php print implode(' ', $row_classes[$count]); ?> termid-<?php print $rows[$count][tid]; ?>">
        <?php foreach ($row as $field => $content): ?>
  <?php if ($field!="tid") { ?>
          <td class="views-field views-field-<?php print $fields[$field]; ?>">
            <?php print $content; ?>
  
          </td>
   <?php } ?>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>
</table>

may be it is not the best way but it works for me :-)

OnkelTem’s picture

Well, I found a kind of solution, but not 100% sure it will work as expected.
The problem with *-table.tpl.php template was that I couldn't find appropriate result set with "excluded" fields.
After digging I've finally found something, it is:

$view->style_plugin->rendered_fields

- an array with _ALL_ fields, including excluded :)

I added shortcut to this in a preprocess:

function THEME_preprocess_views_view_table(&$vars) {
	$vars['raw_result'] = $vars['view']->style_plugin->rendered_fields;
}

and now can access results in *-table.tpl.php like:

foreach ($raw_result as $row) {
  print $row['tid'];
  print $row['title'];
  ...
}
Letharion’s picture

Assigned: Unassigned » esmerel

I think this one could benefit from someone with more experience.

esmerel’s picture

Assigned: esmerel » merlinofchaos
jofdesign’s picture

Version: 6.x-2.9 » 6.x-2.10

I have 2 questions :
- how does it work if the page views display as a other format (no defined format for example) and not as a table format ?
- I'd like to get a field value from an "exclude from display" field in a page-taxonomy-term.tpl.php so I can use this value out of the embedded views. How can I manage this ?

Thank you for your help.

mghatiya’s picture

Subscribing

merlinofchaos’s picture

Status: Active » Fixed

You an almost always find the safely rendered field value in:

$view->style_plugin->rendered_fields[$row_number][$field_id]
alb’s picture

for hide a field, which is the code and the right function?
I founded this functions:
hook_views_pre_render
hook_views_pre_view
hook_views_data_alter
hook_views_handlers

but not found a code example;

I want simple first that the view is visualized, hidden a field ;
by code php and not by set the option inner the view: Exclude from display

so not change directly the query but only the visualization of the page;

other hooks founded
hook_views_pre_execute
hook_views_pre_build
hook_views_data
hook_views_plugins
but think solutioin is in one hook of the first list

merlinofchaos’s picture

The solution is in #12.

alb’s picture

ok, but how can customize and which function to use?
for example for to hide a field image.

this is the view's code

...
$handler->override_option('fields', array(
  'field_image_cache_fid' => array(
    'label' => 'Image',
    'alter' => array(  .... ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'product_list_linked',
    'multiple' => array( 'group' => 1, ....  ),
    'exclude' => 0,
    'id' => 'field_image_cache_fid',
    'table' => 'node_data_field_image_cache',
    'field' => 'field_image_cache_fid',
    'override' => array(  'button' => 'Override', ),
    'relationship' => 'none',
  ),
.............

Status: Fixed » Closed (fixed)

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

pminf’s picture

I had a similar issue: Using a list field named 'field_color' to style my row content. I have used the result array of the view object to solve it:

views-view-fields.tpl.php:

// [...]

if(empty($view->result[$id - 1]->field_field_color) === false)
	$color = $view->result[$id - 1]->field_field_color[0]['raw']['value']; // get field value, which is excluded from display

// [...]
DrCord’s picture

Issue summary: View changes

#7 worked great for me, thank you very much!