如何创建指向由Sulu管理的页面的链接?

huangapple go评论95阅读模式
英文:

How to create a link to a page managed by Sulu?

问题

我正在使用Sulu作为CMS,并添加了一些页面。另外,我有一些自定义的Symfony操作,带有它们自己的twig模板。

现在我想在twig模板中添加一个链接,将用户引导到CMS页面之一。我该如何实现这一点?

我知道sulu-link,但我应该将什么放入它的href属性中?

英文:

I am using Sulu as CMS and added some pages. Additionally I have some custom Symfony actions with their own twig templates.

Now I want to add a link into the twig template that directs the user to one of the CMS pages. How can I achieve that?

I know about sulu-link but what should I put into its href attribute?

答案1

得分: 1

以下是翻译好的部分:

"好吧,这比我想象的要容易。文档中提到:

sulu-link 标签允许通过其 ID 链接到应用程序中的页面和其他实体。该标签的 ID 将在生成响应时进行验证并替换为正确的锚标签。

ID 对应于页面的 UUID,您可以在管理员区域中打开页面的 URL 中找到它。

示例

在管理界面中打开您的页面。假设其 URL 为 https://example.com/admin/#/webspaces/platform/pages/de/f80713e3-1e91-43b8-8351-1f3124b12878/details

要在您的 Twig 模板中创建一个链接,请添加此代码片段:

<sulu-link href="f80713e3-1e91-43b8-8351-1f3124b12878">我的链接标签</sulu-link>
英文:

Well, it is easier than I thought. The doc states

> The sulu-link tag allows to link to pages and other entities in the application by their id. This id of the tag will be validated and replaced by a proper anchor tag when a response is generated.

The id corresponds to the UUID of the page and you can find it in the URL, if you open the page in the admin area.

Example:

Open your page in the administration. Let's say its URL is https://example.com/admin/#/webspaces/platform/pages/de/f80713e3-1e91-43b8-8351-1f3124b12878/details

To create a link in your twig template, add this snippet:

&lt;sulu-link href=&quot;f80713e3-1e91-43b8-8351-1f3124b12878&quot;&gt;label of my link&lt;/sulu-link&gt;

</details>



huangapple
  • 本文由 发表于 2023年3月3日 23:45:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75629160.html
  • sulu
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定