Skip to main content
made the question clearer
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

how to How do I display dynamic field values toin a template?

I am making a module, each time user make content type and add fields to it, all its field values get rendered into static template dynamically.

For This ithis, I am using noad_load_multiple()noad_load_multiple() to get all node values of selected content type and using hook_themehook_theme(), displaying it in a static template page.

$compfields = [node_load_multiple][2](array(), array('type' => $node_type));

return theme('component_fields',array('compfields'=>$compfields));
$compfields = [node_load_multiple][2](array(), array('type' => $node_type));

return theme('component_fields',array('compfields' => $compfields));

In the template file, I am doing it like this way:

print '<p>'.$value->body['und']['0']['value'].'</p>';

byusing the following code, looping over $compfields variable. Now my PROBLEM is : here

print '<p>' . $value->body['und']['0']['value'] . '</p>';

I know that my content type has a body field named body which followis rendered with print '<p>' . $value->body['und']['0']['value'] . '</p>'; pattern to get rendered. But If a user add some additional field, how

How can I render that fieldthe additional fields added to static html structure present in my templatea content type without knowing which type oftheir field he is going to add.type?

how to display dynamic field values to template?

I am making a module, each time user make content type and add fields to it, all its field values get rendered into static template dynamically.

For This i am using noad_load_multiple() to get all node values of selected content type and using hook_theme, displaying it in a static template page.

$compfields = [node_load_multiple][2](array(), array('type' => $node_type));

return theme('component_fields',array('compfields'=>$compfields));

In template file, I am doing it like this way:

print '<p>'.$value->body['und']['0']['value'].'</p>';

by looping $compfields variable. Now my PROBLEM is : here I know that my content type has field named body which follow print '<p>'.$value->body['und']['0']['value'].'</p>'; pattern to get rendered. But If a user add some additional field, how can I render that field to static html structure present in my template without knowing which type of field he is going to add.

How do I display dynamic field values in a template?

I am making a module, each time user make content type and add fields to it, all its field values get rendered into static template dynamically.

For this, I am using noad_load_multiple() to get all node values of selected content type and using hook_theme(), displaying it in a static template page.

$compfields = [node_load_multiple][2](array(), array('type' => $node_type));

return theme('component_fields',array('compfields' => $compfields));

In the template file, I am using the following code, looping over $compfields.

print '<p>' . $value->body['und']['0']['value'] . '</p>';

I know my content type has a body field which is rendered with print '<p>' . $value->body['und']['0']['value'] . '</p>';.

How can I render the additional fields added to a content type without knowing their field type?

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
Sugandh Khanna
  • 3.5k
  • 5
  • 40
  • 69

how to display dynamic field values to template?

I am making a module, each time user make content type and add fields to it, all its field values get rendered into static template dynamically.

For This i am using noad_load_multiple() to get all node values of selected content type and using hook_theme, displaying it in a static template page.

$compfields = [node_load_multiple][2](array(), array('type' => $node_type));

return theme('component_fields',array('compfields'=>$compfields));

In template file, I am doing it like this way:

print '<p>'.$value->body['und']['0']['value'].'</p>';

by looping $compfields variable. Now my PROBLEM is : here I know that my content type has field named body which follow print '<p>'.$value->body['und']['0']['value'].'</p>'; pattern to get rendered. But If a user add some additional field, how can I render that field to static html structure present in my template without knowing which type of field he is going to add.