I my custom content type having a field body which is of type "Long text and summary" and $node object of it does not contain any safe_value as you're checking in block_inject.module.


  if (isset($node->body[$language_content->language])) {
              $body = $node->body[$language_content->language]['0']['safe_value'];
            }

So please tell me what needs to be done.

Also I'v read from http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way that

$output = field_view_field('node', $node, 'field_name');

is portable and right way to get body field's value.

Comments

upchuk’s picture

Hello!

Thanks for letting me know. Can you please tell me what exactly did you do to encounter this issue? How come you don't have the safe_value? What kind of custom content type did you create?

Thanks!

D

rag_gupta’s picture

I've no idea why this safe_value isn't there. I myself was unaware about it. Mine is the latest Drupal code(recently updated).

For time being I've simply replaced the 'safe_value' with 'value' and it's working fine.

It wasn't working with my three content types which describe company jobs. I understand when we create a node type content type the Body field comes by default. So I'm not sure why it isn't there.

I've checked my another site using D7 and through Devel tab I can't find this value in the body either.

upchuk’s picture

That is very weird..Do your article and basic page content types also lack the safe_value for the body?

upchuk’s picture

Are you using the Node Embed module or some particular module that deals with nodes or text filters?

rag_gupta’s picture

StatusFileSize
new18.73 KB
new39.11 KB

No idea. I've checked the node of page type( ie about us page) and there is no safe_value. Pl. see the screenshot. I'm also uploading list of enabled modules.

rag_gupta’s picture

StatusFileSize
new33.06 KB

Pl. delete this file: Graphic_15-Oct-13 7_39_57 PM.png in the last post.

Here is the correct one.

upchuk’s picture

Status: Active » Postponed (maintainer needs more info)

I think one of the modules has disabled the appearance of the safe_value item. Do a cross check of the modules you use on both sites you mentioned and try disabling one by one to see which one it is. You should have the safe_value there..

Star maybe with these ones: simplehtmldom API, Text formatter (textformatter). Maybe it has something with the text formatting.

Lemme know how it goes.

upchuk’s picture

i cannot delete the file..

rag_gupta’s picture

Yes you're right .. I'll check sometime which filter is removing this value and why. This is of concern.

Moreover safe_value will not work I think if I use basic text format because then html special characters will be encoded.

upchuk’s picture

safe_value should be there for all the normal text formats: plain text, filter html, full html...

D

upchuk’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
upchuk’s picture

Issue summary: View changes

minor grammar correction