![](/img/trans.png)
[英]How to create a desktop shortcut (link), but with own shortcut file extension (e.g. .appfolder) instead of .lnk programmatically in C#?
[英]How to add a shortcut link programmatically in Drupal 9?
嘗試添加一些快捷鏈接我收到此錯誤
致命錯誤:InvalidArgumentException:URI“”無效。 您必須使用有效的 URI 方案。 在../core/lib/Drupal/Core/Url.php:293
use Drupal\shortcut\Entity\Shortcut;
$taxo_shorcut = Shortcut::create([
'shortcut_set' =>'default',
'title' => 'Test',
'link' => 'admin/structure/taxonomy',
]);
$taxo_shorcut->save();
有什么幫助嗎?
使用internal:
方案使用uri
鍵值正確構建 URI 結構:
$taxo_shorcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => 'Test',
'link' => [
'uri' => 'internal:/admin/structure/taxonomy',
],
]);
$taxo_shorcut->save();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.