2

I would like to assign some content from a node, lets say the body field, into a region. so I cannot theme this content in my node.tpl.php

In the template_process_page(&$vars) i can easily set $page['my_region'] = HTML.

with $vars['node']->body i can access to my body field dada. from there I would like to use the regular theme function to render the body field. to use theme('field',$variables) or render($variables) I need to bring the body-array from:

Array ( [und] => Array ( [0] => Array ( [value] => TEXT [summary] => [format] => full_html [safe_value] => TEXT [safe_summary] => ) ) )

to sth like:

Array ( [#theme] => field [#weight] => 1 [#title] => Body [#access] => 1 [#label_display] => hidden [#view_mode] => full [#language] => und [#field_name] => body [#field_type] => text_with_summary [#field_translatable] => 0 [#entity_type] => node [#bundle] => article [#object] => stdClass Object (...) [#items] => Array ( [0] => Array ( [value] => TEXT [summary] => [format] => full_html [safe_value] => TEXT [safe_summary] => ) ) [#formatter] => text_default [0] => Array ( [#markup] => TEXT ) )

But I don't know how exactly. how can a generate my field with the second array-achitecture. if possible without more db-queries.

thank you for help!

1 Answer 1

5

You are looking for field_attach_view

What you would need to do, with your loaded node is something like this:

$fields = field_attach_view('node', $node, 'full'); $body = $fields['field_body']; 
1
  • perfect!!! thank you very much. i spend the whole day reading the api doc. Commented Aug 20, 2011 at 21:12

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.