SharePoint 发布 HTML 字段控件将相对 URL 转换为绝对 URL [英] SharePoint Publishing HTML Field Control Converts Relative URL to Absolute URL

查看:33
本文介绍了SharePoint 发布 HTML 字段控件将相对 URL 转换为绝对 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在对我们是否应该在面向外部的 SharePoint 网站上使用 CEWP 或 HTML 字段控件进行大量研究后,我们决定使用字段控件(非常感谢 AC).现在,我们遇到了一个问题,我读过的所有博客都说不应该是问题.

So, after much research on whether or not we should the CEWP or the HTML Field Control on an external facing SharePoint site, we settled on using the Field Control (much thanks to AC). Now, we are having an issue that all the blogs I read say should not be an issue.

当我们将相对 URL 放入 HTML 编辑器并点击确定"时,它会自动更改为绝对 URL.从我一直在做的一些研究来看,这显然是 Internet Explorer 的一个功能".TinyMCE 有一个解决方法.我想知道是否有一些解决我缺少的 SharePoint 控件的方法.

When we put a relative URL into the HTML Editor and hit OK, it is automatically changed to an absolute URL. This is apparently a "feature" of Internet Explorer from some of the research I have been doing. TinyMCE has a work around for this. I was wondering if there was some work around for the SharePoint control that I am missing.

这对我们来说是个大问题,因为我们有一个创作网站和 www 网站.因此,当在创作站点上完成创作并且所有链接都迁移到 www 站点时,它们是 http://authoring.domain.com/en-us/Pages/...而不是 /en-us/Pages/...

This is kind of a big issue for us because we have an authoring site and the www site. So, when the authoring is done on the authoring site and all the links get migrated to the www site, they are http:// authoring.domain.com/en-us/Pages/... instead of /en-us/Pages/...

推荐答案

我也遇到了这个问题.我们通过功能部署了自定义站点字段和内容类型.HTML 字段的 RichText 属性在 caml 中正确为 true,但是一旦在根 Web 字段集合和每个页面列表中部署 SPField,RichText 属性就会变为 false.

I encountered this issue as well. We had custom site fields and content types deployed via feature. The RichText property of the HTML Field is properly as true in caml, but once deployed the SPField in the root web fields collection and every Pages list the RichText attribute becomes false.

通过在部署网站栏和内容类型的功能上使用功能接收器,我能够成功解决该问题.我的代码循环网站中的每个网站,然后迭代字段以更新它们.

I was able to successfully resolve the issue by using a feature receiver on the feature that deploys the site columns and content types. My code loops every web in the site and then iterates over the fields to update them.

代码片段:

    private void processweb(SPWeb web)
    {
        SPList list = web.Lists["Pages"];

        SPField field;
        for (int i = 0; i < list.Fields.Count; i++)
        {
            field = list.Fields[i];
            //to work around a sharepoint defect ... make html fields work in richtext mode
            if (field != null && string.Compare(field.TypeAsString, "HTML", true) == 0 && (field as SPFieldMultiLineText).RichText == false)
            {
                (field as SPFieldMultiLineText).RichText = true;
                field.Update(true);
            }
        }

        foreach (SPWeb w in web.Webs)
        {
            processweb(w);
        }
    }

这篇关于SharePoint 发布 HTML 字段控件将相对 URL 转换为绝对 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆