我有一个文件字段。在页面上呈现如下
<a href="http://somesite/somefolder/9.doc" type="application/msword; length=392192">9.doc</a>我想把它锁起来
<a href="http://othersite/otherfolder/9.doc" type="application/msword; length=392192">9.doc</a> core/themes/bartik/templates/classy/field/file-link.html.twig 1:( 1 :我已经尝试将复制到我的主题中,并将其重命名为文件名建议--链接-用户-checklist.html.twig,但仍有核心模板可供呈现。
2 :(,我试图通过checklistheme_preprocess_file_link更改url,但是$checklistheme_preprocess_file_link‘->setFileUri($my_url));但是这个方法不存在。
3 :( T试图向checklist_preprocess_paragraph添加自定义元素(&$变量),但没有显示
我不知道我还能做什么
发布于 2021-07-28 14:48:40
发现我自己
function MYTHEME_preprocess_file_link(&$variables) {
$file = \Drupal\Core\Url::fromUri('some_url');
$variables['link']['#url'] = $file;
}https://stackoverflow.com/questions/68561674
复制相似问题