【问题标题】:Display a list of file(s) depending on the value of a specific field in Drupal 6?根据 Drupal 6 中特定字段的值显示文件列表?
【发布时间】:2011-06-25 10:58:30
【问题描述】:

我在我的 Drupal 6 站点上创建了一个新的“工作”内容类型,以使管理员能够发布新工作。

内容类型有一个名为 job_type 的隐藏字段,它可以有 4 种可能值中的一种:Instructor、Lecturer、Manager 或 Support。

如何配置 Drupal 以根据 job_type 字段的值动态显示下载的文件列表?

所需文件已在服务器上。

例如:

if job_type = Manager, show: file1.pdf, file2.pdf
if job_type = Support, show: file1.pdf, file3.pdf, file5.pdf
if job_type = Lecturer, show: file1.pdf, file4.pdf

谢谢

【问题讨论】:

    标签: drupal download


    【解决方案1】:

    查看Computed Field module

    类似

    if ($node->field_job_type[0]['value']==Manager) { 
    $node_field[0]['value'] = "path_to_file1.pdf";
    $node_field[1]['value'] = "path_to_file2.pdf";
    }
    

    然后配置显示以打印文件链接。

    http://drupal.org/node/126522的文档中有很多代码sn-ps

    【讨论】:

    • @Chaulky @keva - 感谢您的帮助。我使用上面的示例实现了一个计算字段,如下所示:if($node->field_job_type[0]['value']==Instructor) { $node_field[0]['value'] = "sites/default/files/file1.pdf"; $node_field[1]['value'] = "sites/default/files/file5.pdf";}...。如何配置 job_list 视图以显示下载这些文档的超链接?我不知道为什么,但 2 个必需的 PDF 文件中只有 1 个被列为“sites/default/files/file1.pdf”,我不确定如何将此路径显示为链接。有任何想法吗?谢谢。
    猜你喜欢
    • 2020-06-12
    • 2011-07-15
    • 1970-01-01
    • 2021-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 2019-04-17
    相关资源
    最近更新 更多