2012-07-22 126 views
1

我有一个名为'field_downloads'的字段,它是一个允许用户上传最多10个文件的文件字段。我该如何在page.tpl.php中渲染这些内容?渲染文件drupal

下面是从page.tpl.php中输出:

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

enter image description here

+0

你是什么意思?渲染出这些? – 2012-07-23 08:50:38

+0

作为链接my file decrition LeBlaireau 2012-07-23 10:10:15

回答

1

您可以简单地将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()

希望这个作品......穆罕默德什么。

1

你这样做,因为任何其他领域:

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

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

+0

这只会在节点工作? – LeBlaireau 2012-07-23 13:47:37

0
<?php 
     $file_uri=$node->my_field['und']['0']['uri']; 
     $file_path = file_create_url($file_uri); 
     print "<a href='".$file_path."'>here</a>"; 
    ?>