Skip to main content
added 8 characters in body
Source Link
M a m a D
  • 3.8k
  • 2
  • 33
  • 63

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
wrapper_prefix; ?>  
 <?php print $field->wrapper_prefix; ?> <?php print $field->label_html; ?> <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p>    <?php print $field->wrapper_suffix; ?> 
wrapper_suffix; ?>

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
wrapper_prefix; ?>
<?php print $field->label_html; ?> <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p> 
wrapper_suffix; ?>

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
 
 <?php print $field->wrapper_prefix; ?> <?php print $field->label_html; ?> <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p>    <?php print $field->wrapper_suffix; ?> 
deleted 37 characters in body
Source Link
srodrig
  • 145
  • 2
  • 14

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
wrapper_prefix; ?>
<?php print $field->label_html; ?> <?php print $field->content; ?>  <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p> 
wrapper_suffix; ?>

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
wrapper_prefix; ?>
<?php print $field->label_html; ?> <?php print $field->content; ?>  <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p> 
wrapper_suffix; ?>

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
wrapper_prefix; ?>
<?php print $field->label_html; ?> <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p> 
wrapper_suffix; ?>
added 1088 characters in body
Source Link
srodrig
  • 145
  • 2
  • 14

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
wrapper_prefix; ?>
<?php print $field->label_html; ?> <?php print $field->content; ?> <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p> 
wrapper_suffix; ?>

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables) { $view = $variables['view']; if($view->name == "news_main_list") { $variables['news_date'] = $variables['fields']['field_news_date_text']->content; $variables['news_type'] = $variables['fields']['field_news_type']->content; $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1'; } } 

My views-view-fields--news-main-list--block-1.tpl.php file:

 <?php if (!empty($field->separator)): ?> <?php print $field->separator; ?> 
wrapper_prefix; ?>
<?php print $field->label_html; ?> <?php print $field->content; ?> <p class="newsTitle"><?php print $fields['title']->content; ?></p> <p class="dateByLine"> <?php print $news_date; ?> | <?php print $news_type; ?> <?php if ($news_type == "event") : ?> <?php print 'hello'; ?> <?php endif; ?> </p> 
wrapper_suffix; ?>
edited title
Link
srodrig
  • 145
  • 2
  • 14
Loading
Source Link
srodrig
  • 145
  • 2
  • 14
Loading