1

我有一个名为“field_downloads”的字段,它是一个文件字段,允许用户上传最多 10 个文件。如何在 page.tpl.php 中呈现这些?

以下是 page.tpl.php 的输出:

$x = node_view($node);
dsm($x['#node']->field_downloads);

在此处输入图像描述

4

3 回答 3

1

您可以像任何其他字段一样执行此操作:

print render($content['FIELD_NAME']);

在您的内容类型的管理显示页面中,将文件字段设置为“文件表”

于 2012-07-23T09:01:40.147 回答
1

您可以简单地编写以下代码。

$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 ()你需要知道的

希望这行得通……穆罕默德。

于 2012-07-23T10:35:02.137 回答
1
   <?php 
       $file_uri=$node->my_field['und']['0']['uri'];   
       $file_path = file_create_url($file_uri);
       print "<a href='".$file_path."'>here</a>";
   ?>
于 2015-10-05T15:08:27.547 回答