Orchard CMS 在 HTML 小部件中添加链接

发布于 2024-11-28 05:04:28 字数 287 浏览 0 评论 0原文

我正在尝试在 HTML 小部件中添加指向页面的链接。

我目前正在将 orchard 作为虚拟目录运行,因此无法使用 '/'。另外,由于我正在开发站点上工作,然后复制到实时站点,所以我不确定该站点是否将作为虚拟目录运行或从根目录运行。

我刚刚意识到通过 HTML 小部件输入的所有链接都会有问题,因为您不能使用 '~',而且看起来图像链接是固定的,因此部署到不同的位置不起作用,即。从 localhost\dev 到 localhost\live

有什么想法吗?

I'm trying to add links to pages in the HTML widget.

I'm currently running orchard as a virtual directory, so I can't use '/'. Also since I'm working on a dev site then copying over to a live site, I'm not sure if the site will be running as a virtual directory or from the root.

I've just realised that all links entered via the HTML widget will have a problem, since you can't use '~', also it looks like the image links are fixed, so deploying to a different location won't work ie. from localhost\dev to localhost\live

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秉烛思 2024-12-05 05:04:28

如果您从 html 编辑器输入它,您别无选择,只能使用根路径 (/foo)。当然,如果您随后从虚拟目录发布到没有虚拟目录的站点,可能会导致问题,但目前就是这样。我们正在寻找解决方案,但与此同时,您最好的选择是拥有一个尽可能接近生产设置的开发站点。

If you're entering it from the html editor, you don't have any choice but to use a rooted path (/foo). Sure, it can cause problems if you then publish from a vdir into a site without a vdir, but that's how it for now. We're looking at solutions but in the meantime your best bet is to have a dev site that is as close as possible to the production setup.

迷爱 2024-12-05 05:04:28

As pointed out by randompete on codeplex, another solution could be implementing your own IHtmlFilter. I wrote a simple implementation which you can find here: http://orchard.codeplex.com/discussions/279418
It basically post-processes the BodyPart text by replacing all occurences of urls starting with ~/ with a resolved url (using the UrlHelper.Content() method)

噩梦成真你也成魔 2024-12-05 05:04:28

如果您需要显示指向静态资源的链接,您可以使用:

@Html.Link(string textlink, string url) 

Html.Link 不支持应用程序相关 url(~/[...] 的)

但如果您只需要 href (对于 img ),则 。它支持〜/ url。

src='@Href(string url)'

如果您需要显示操作的链接

 @Html.ActionLink(...) <-- lots of overloads.

If you need to display a link pointing to a static resource, you can use:

@Html.Link(string textlink, string url) 

But Html.Link doesn't supports application relatives urls (~/[...] ones)

if you need only the href (as for an img ). It supports ~/ urls.

src='@Href(string url)'

If you need to display a link to an action

 @Html.ActionLink(...) <-- lots of overloads.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文