2011-09-22 65 views
1

我是新來的Drupal主題,並試圖爲我具有的特定內容類型創建自定義主題模板。Drupal render()強制其他div關閉?

我試圖如下:

<div<?php print $content_attributes; ?>> 


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

    <div class="field-label-above property-information"> 
     <div class="field-label">Property Information</div> 
     <?php print render($content['address']); ?> 

    </div> 

</div> 

然而,當內容實際呈現的地址部分被趕出其父DIV的,看起來像這樣:

<div class="field-label-above property-information"> 
    <div class="field-label">Property Information</div> 

</div> 
<div class="field field-name-field-property-address field-type-addressfield field-label-inline clearfix"><div class="field-label">Address:&nbsp;</div><div class="field-items"><div class="field-item even"><div class="street-block"><div class="thoroughfare">55 Duchess Ave</div></div><div class="addressfield-container-inline locality-block"><span class="locality">London</span>&nbsp;&nbsp;<span class="state">Ontario</span>&nbsp;&nbsp;<span class="postal-code">N6C 1N3</span></div><span class="country">Canada</span></div></div></div> 

我不能弄清楚爲什麼會發生這種情況,或者解決方案是如何將地址保留在我手動創建的div內。

想法?

+0

實際上,我看到這也和我沒有什麼事,那就是改變節點輸出,我可以找到。只是爲了幫助指出,這個問題在其他地方經歷過,並不一定是古怪的。 –

回答

1

這可能發生的唯一可能的方式是,如果您有自定義模塊或投稿模塊攔截您的模板文件並更改模板,或者您已啓用某個JavaScript將<div>移出容器。 Drupal在處理模板文件時絕對不會對內容進行重新排序,因此Drupal內核中的任何內容都不會導致問題。

如果<div>只顯示在容器外部(即當您檢查源代碼時它在裏面),那麼您可能只是面臨浮動問題;只需將clearfix類添加到包含元素。

編輯

只是一個想法,你清除緩存,因爲你添加的模板文件?如果沒有,那麼,它將不會被拾取,直到緩存被清除。

此外,如果這是一個自定義節點模板(即節點 - page.tpl.php中),請確保你也node.tpl.php拷貝到你的主題文件夾。然後再清除緩存。