Search code examples
drupaldrupal-7drupal-modulesdrupal-views

How do I tell my field in my module to handle the value as FULL HTML?


Ok so I have created a drupal module that retrieves data stored in a database. The field in question contains html code for its value. I want to take that html code and have it utilized for what its value is in drupal. So if it has a list in the code I want it to display the list so on and so forth.

Here is my code for my module.

<?php

/**
* @file
*/

/**
 * Implements hook_views_data()
 */
function jobs_views_data() {
  $data['Jobs']['table']['group'] = t('Jobs');
  $data['Jobs']['table']['base'] = array(
    'field' => 'JobID',
    'title' => t('Jobs'),
    'help' => t('This table shows a list of all jobs.'),
    'database' => 'MyDatabase'
  );


  $data['Jobs']['JobID'] = array(
      'title' => t('Job ID'),
      'help' => t('A unique job id'),
      'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
      'argument' => array(
      'handler' => 'views_handler_argument_numeric',
    ),
      'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
      'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['Jobs']['Active'] = array(
      'title' => t('Active'),
      'help' => t('A field representing whether or not a job is active.'),
      'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
      'argument' => array(
      'handler' => 'views_handler_argument_numeric',
    ),
      'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
      'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['Jobs']['DivisionID'] = array(
      'title' => t('Division ID'),
      'help' => t('A unique division id associated with a job.'),
      'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
      'argument' => array(
      'handler' => 'views_handler_argument_numeric',
    ),
      'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
      'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['Jobs']['JobTitle'] = array(
      'title' => t('Job Title'),
      'help' => t('Job title'),
      'field' => array(
      'click sortable' => TRUE,
    ),
      'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );


  $data['Jobs']['JobHTML'] = array(
      'title' => t('Job HTML'),
      'help' => t('Job HTML.'),
      'field' => array(
        'click sortable' => TRUE,
    ),
      'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );


  return $data;
}

So as you can see that last field there JobHTML needs a handler for the field. I have tried setting it to 'handler' => 'views_handler_field_markup'. Oddly enough it did seem to lay the html out correctly as it should, but then it left the HTML code inside of the content.


Solution

  • I have finally solved this problem after months here