Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

So I'm able to create a page programmatically, BUT even though I'm specifying the 'full_html' filter, the page is being created with the 'filtered_html' filter which means that the code I'm writing to the page after it's created is being stripped out. Here's the line I'm using to set the filter type:

$node->body[$node->language][0]['format'] = 'full_html';

Why is the filter type being ignored when the node is created?

Thanks in advance, Bryan

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

OK, as it turns out, the 'body' field is not called 'body' in our Drupal installations; it's called 'field_page_body'. Changing that in the code made everything work.

share|improve this answer
add comment

It could very well be due to the default weight of the filter. You set this in content authoring > input formats

just make "full html" the first option. let me know if that works as I had a similar issue before.

share|improve this answer
    
That worked-- of course, now if I want to create nodes with other filter types, they won't work. Not sure if this is a bug, or if I'm doing something horribly wrong (although the code above is how it's done in numerous tutorials I've read). Thanks for the workaround-- it may do the trick for me for the time being. –  Bryan Green Jan 16 '13 at 22:19
    
OK, as it turns out, the 'body' field is not called 'body' in our Drupal installations; it's called 'field_page_body'. Changing that in the code made everything work. –  Bryan Green Jan 17 '13 at 0:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.