【问题标题】:Print twig variable inside function在函数内打印树枝变量
【发布时间】:2017-01-23 13:45:32
【问题描述】:

如何输出变量 target_id 而不是 node.nid?在函数调用内部?

{% set target_id = content.field_internal_lnk %} <a href="{{ path('entity.node.canonical', {'node': node.nid }) }}">{{ content.field_button_text }}</a>

【问题讨论】:

    标签: drupal twig


    【解决方案1】:

    使用正确的变量名?

    {'node': target_id }
    

    【讨论】:

    • 我就是这么做的。我已经解决了这个问题。 target_id 不是原始值。
    • path() 扩展了一个整数。我传递的 target_id 值是一个数组。这就是问题所在。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 1970-01-01
    • 2023-02-03
    • 1970-01-01
    • 2013-05-11
    • 1970-01-01
    相关资源
    最近更新 更多