Orchard CMS Adding a links in HTML widget

China☆狼群 提交于 2019-12-12 12:09:14

问题


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?


回答1:


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.




回答2:


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)




回答3:


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.


来源:https://stackoverflow.com/questions/6954041/orchard-cms-adding-a-links-in-html-widget

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!