سؤال

I am looking to customize the templated output of the $content variable in node.tpl.php Can you tell me how I could achieve this? Is is possible with another template file?

The reason for this is to achieve AJAX pagination thus I need an ID on node_body and also to pull out the paging nav from this same DIV.

Any help appreciated!

هل كانت مفيدة؟

المحلول 2

You need to delete the $content variablee from node.tpl.php and use the separate fields of $node. You can view the fields with print_r($node)

نصائح أخرى

Copy the node.tpl file and rename it to node-contenttypename.tpl.php. After doing this you can print the fields using this code

print $node->field_name[0]['view'] ?>


to print body use this code

print strip_tags($node->content ['body']['#value']);


to print gallery use this code or you can use views


print if($node->field_gallery[0]['view']==null){ print " "; } else
{

foreach ((array)$node->field_gallery as $item) { print $item['view']


i hope you can get ideas using this code.
You can see example from this live site http://www.richtown.ae/?q=content/most-wanted-property-one-bed-residences-dial-0555456012-0
Thanks http://www.richtown.ae

Yes you can create another template file for that particular content type. using naming convention node-[content-type-name].tpl.php Naming convention of template file is very much important in Drupal. Put this file into templates folder of theme directory. and print $node and replace $content variable with the fields you want.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top