Which doesn't make sense as most feeds contain HTML, so this should default to using the filtered_html input format. And the importer should also probably store its format value by format machine name and not format ID.

Comments

aangel’s picture

I'm encountering this as well and here is my workaround:

/*
 * Implements hook_node_presave
 */
function mare_admin_node_presave($node) {
  //
  // Workaround for Feeds module setting text format to Plain Text instead of Full HTML or Filtered HTML
  //
  switch ($node->type) { 
    case 'feed_whoi':
    case 'feed_mbari':
    case 'feed_monterey_bay':
    case 'feed_noaa':
    case 'feed_scripps':
    case 'feed_whoi_top_stories':
    case 'feed_whoi':
      $node->body['und'][0]['format'] = 'full_html';
      break;
  }
}
lawnmower528’s picture

Where did you place this patch? Could you provide a .patch file?

aangel’s picture

Well, now I'm no longer sure that the module isn't working as designed and I won't be looking into it again today. If you find that the text format setting isn't working for you, place code similar to the above in a custom module (it's not a modification to existing code, it's brand new code):
Creating Drupal 7.x modules

For a single feed you can get away with just the following:

/*
 * Implements hook_node_presave
 */
function yourmodulename_node_presave($node) {
  //
  // Workaround for Feeds module setting text format to Plain Text instead of Full HTML or Filtered HTML
  //
  if ($node->type == 'feed_whoi') {
      $node->body['und'][0]['format'] = 'full_html';
  }
}

Clear your cache and then every time the feed node is about to be saved the format will be set to 'full_html.'

Here is the documentation on Drupal 7 hooks:
http://api.drupal.org/api/drupal/includes--module.inc/group/hooks/7

hellomobe’s picture

Another solution is to use the check_markup() on the field output (I placed it in the node.tpl file).

irwin nerwin’s picture

My inner hacker wanted to try the code posted above, for a single feed. (Thanks for the tip to Creating Drupal 7.x modules. I think.) The Creating D7 Modules article was clear and easy to follow. I created and enabled my first module! It didn't change anything. Maybe didn't do anything. But OTOH, it didn't break anything either! So, that was exciting. Perhaps I have done something wrong. Perhaps I have the whole source of the problem wrong! But I learned to create a module, even if it didn't do anything. Hacker thrills.

Edited to remove earlier idiotic ramblings and leave the following revised idiotic ramblings.

In case anyone else needing to know might stumble on this: With CSV (or TSV) files, one puts "double-quote marks" around textish fields, and one doubles-up any double-quotes inside the field. Yeah, I used to know that. Now I know it again. "Hi, I'm a field value." and """Hi,"" she said. ""I'm a field value.""" Also helps if editing the file with, say, Notepad, to save as utf-8 instead of ANSI. Thanks to the developers for the Feeds module, which works fine… once the data is formatted correctly!]

dooug’s picture

Status: Active » Fixed

I think this no longer applies (or at least the work-arounds aren't necessary) because you can set the text format on the Node processor settings and (depending on the parser you are using, I am using querypath) you can choose "Select the queries you would like to return raw XML or HTML " for fields targets on the import form.

Status: Fixed » Closed (fixed)

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

kpv’s picture

+1. at least for Body field your can set text format

giorgio79’s picture

Status: Closed (fixed) » Active

How do I set the input format for text fields other than the body?

tondeuse’s picture

Thanks so much, Dave Reid for this little hack, it saved me a ton of time on a large imported database with a long array of fields.

Here is my take on your suggestion, the big change here is that I validate that no row is created in the affected tables in the DB, as $node->body['und'][0]['format'], actually creates a record in the table.

A dsm($node) shows that format is a child of [0], just as well as the child value. The following code checks that [0] exists (therefore has children) before format asignation. It also takes into account that for repeatable fields, the [0] could become one [1] and so on, using deltas.

As my content type contained a field collection with 3 fields, not affected by the node_presave process, I completed the job hitting the db directley with a query to wrap it up. (see comments)

function vdm_feeds_importer_helper_eplv_node_presave($node){
 switch ($node->type) { 
  case 'ravageurs_maladies':
       //dsm($node);
       $localfields= array('field_mal_conditions_favorables',
                          'field_mal_controle_biologique', 
                          'field_mal_controle_chimique', 
                          'field_mal_controle_physique', 
                          'field_mal_depistage', 
                          'field_mal_desc_cycle_dev', 
                          'field_mal_mesures_preventives', 
                          'field_mal_methodes_intervention', 
                          'field_mal_plantes_hotes', 
                          'field_mal_resume', 
                          'field_mal_signes_symptomes'
                          );
                          
        foreach($localfields as $f){
          // For each field for which a value exists (delta)...
          foreach($node->{$f}['und'] as $delta => $value){
            //Set format to "full_html"
            $node->{$f}['und'][$delta]['format'] = 'full_html';
          }
        }                    
    break;
    case 'carnet_horticole':
      $localfields= array('field_hor_arrosage_fert',
                          'field_hor_cond_croissance', 
                          'field_hor_especes', 
                          'field_hor_facilite_culture', 
                          'field_hor_multiplication', 
                          'field_hor_rav_maladies', 
                          'field_hor_origine_descr', 
                          'field_hor_toxicite', 
                          'field_hor_rempotage', 
                          'field_hor_repartition', 
                          'field_hor_taille_entretien',
                          'field_hor_utilisation'
                          );
      foreach($localfields as $f){
          // For each field for which a value exists (delta)...
          foreach($node->{$f}['und'] as $delta => $value){
            //Set format to "full_html"
            $node->{$f}['und'][$delta]['format'] = 'full_html';
          }
        }
    /*
      ** Execute the following sql commands in phpmyadmin, 
      *  for field collections, not affected by the current routine : 
    
     «
     UPDATE `field_data_field_hor_symptomes` SET `field_hor_symptomes_format` = 'full_html';
     UPDATE `field_data_field_hor_solutions` SET `field_hor_solutions_format` = 'full_html';
     UPDATE `field_data_field_hor_causes_possibles` SET `field_hor_causes_possibles_format` = 'full_html';
     »
     */
    break;
  } 
}
twistor’s picture

Title: Feed items created with 'Plain text' input format by default » Update Feeds News feature
Assigned: dave reid » Unassigned

Hijacking your issue :)

As far as I can gather, this only applies to the "Feeds News" feature. Feeds currently stores filter formats by machine name.

Will depend on #1588938: Allow selection of filter for each text field imported.

eriknewby’s picture

If you copy paste the block above (comment #3), make sure you take a look at your node object. In my case, my "body" field is actually "field_feed_item_description".
Thanks for sharing aangel.

ibar’s picture

The input format can be set on the Processor settings page as noted in #6 but since the upgrade to feeds-7.x-2.0-alpha6 it doesnt work any more. Although I have set it to Filtered HTML it imports the body of the node in plain text, so in order to work I have to open the created node and resave it.
Is there a fix for this?

aangel’s picture

Component: Feeds News » Code
Issue summary: View changes
Status: Active » Closed (outdated)