Orchard CMS 在 HTML 小部件中添加链接
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您从 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.
正如 codeplex 上的 randompete 指出的那样,另一种解决方案可能是实现您自己的 IHtmlFilter。我编写了一个简单的实现,您可以在这里找到: http://orchard.codeplex.com/discussions/279418< /a>
它基本上通过将所有出现的以 ~/ 开头的 url 替换为已解析的 url(使用 UrlHelper.Content() 方法)来对 BodyPart 文本进行后处理
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)
如果您需要显示指向静态资源的链接,您可以使用:
Html.Link 不支持应用程序相关 url(~/[...] 的)
但如果您只需要 href (对于 img ),则 。它支持〜/ url。
如果您需要显示操作的链接
If you need to display a link pointing to a static resource, you can use:
But Html.Link doesn't supports application relatives urls (~/[...] ones)
if you need only the href (as for an img ). It supports ~/ urls.
If you need to display a link to an action