我有一個名爲'field_downloads'的字段,它是一個允許用戶上傳最多10個文件的文件字段。我該如何在page.tpl.php中渲染這些內容?渲染文件drupal
下面是從page.tpl.php中輸出:
$x = node_view($node);
dsm($x['#node']->field_downloads);
我有一個名爲'field_downloads'的字段,它是一個允許用戶上傳最多10個文件的文件字段。我該如何在page.tpl.php中渲染這些內容?渲染文件drupal
下面是從page.tpl.php中輸出:
$x = node_view($node);
dsm($x['#node']->field_downloads);
您可以簡單地將f下面的代碼。
$list_of_paths = array();
foreach($x['#node']->field_downloads['und'] as $index => $data)
{
$file_uri = $data['uri'];
$file_path = file_create_url($file_uri);
$list_of_paths[] = l(t("my file direction"), $file_path);
}
print theme("item_list", array(
'items' => $list_of_paths,
'type' => 'ul',
'title' => t('List of file paths.'),
));
這裏有您需要了解file_create_url()
希望這個作品......穆罕默德什麼。
你這樣做,因爲任何其他領域:
print render($content['FIELD_NAME']);
在你的內容類型的管理顯示頁面集將文件字段設置爲「文件表」
這隻會在節點工作? – LeBlaireau 2012-07-23 13:47:37
<?php
$file_uri=$node->my_field['und']['0']['uri'];
$file_path = file_create_url($file_uri);
print "<a href='".$file_path."'>here</a>";
?>
你是什麼意思?渲染出這些? – 2012-07-23 08:50:38
作爲鏈接my file decrition – LeBlaireau 2012-07-23 10:10:15