2015-10-07 4 views
0

с помощью Drupal 7 как вы можете настроить node.tpl.php для отображения изображения перед заголовком. Я хотел бы организовать свой HTML структуру разметки, как:Редактировать Drupal 7 template - node.tpl.php

<div id="node-id" class="class"> 
    <div class="content"> 
    <div class="field-name-field-graphic"><img src="Untitled-2.png"></div> 
    <h2>tilte</h2> 
    <div class="field field-name-body"> 
     <p>body</p> 
    </div> 
    </div> 
</div> 

На «node.tpl.php» я не вижу переменную для поля имя-поля-графики. Где это ручка?

Ниже node.tpl.php

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>> 

    <?php print $user_picture; ?> 

    <?php print render($title_prefix); ?> 
    <?php if (!$page): ?> 
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2> 
    <?php endif; ?> 
    <?php print render($title_suffix); ?> 

    <?php if ($display_submitted): ?> 
    <div class="submitted"> 
     <?php print $submitted; ?> 
    </div> 
    <?php endif; ?> 

    <div class="content"<?php print $content_attributes; ?>> 
    <?php 
     // We hide the comments and links now so that we can render them later. 
     hide($content['comments']); 
     hide($content['links']); 
     print render($content); 
    ?> 
    </div> 

    <?php print render($content['links']); ?> 

    <?php print render($content['comments']); ?> 

</div> 

ответ

0

Вы можете найти его в переменной $ узла, который является объектом узла, имеющего все данные.

0

Эта линия print render($content); печатает все ваше содержание узла, так чтобы напечатать одну определенную область вы идете, как это: print render($content['field_name_field_graphic']);

3

Пожалуйста, пройти через ниже код, если это помогает.

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>> 

    <?php print $user_picture; ?> 

    <?php print render($title_prefix); ?> 
    <?php if (!$page): ?> 
    <div class="field-name-field-graphic"> <?php print render($content['field_name_field_graphic']);?> </div> 
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2> 
    <?php endif; ?> 
    <?php print render($title_suffix); ?> 

    <?php if ($display_submitted): ?> 
    <div class="submitted"> 
     <?php print $submitted; ?> 
    </div> 
    <?php endif; ?> 

    <div class="content"<?php print $content_attributes; ?>> 
    <?php 
     // We hide the comments and links now so that we can render them later. 
     hide($content['comments']); 
     hide($content['links']); 
     hide($content['field_name_field_graphic']); 
     print render($content); 
    ?> 
    </div> 

    <?php print render($content['links']); ?> 

    <?php print render($content['comments']); ?> 

</div>