获取页面所有者的联系电子邮件并在SharePoint 2010母版页中显示 [英] Get Page owner contact email and display in SharePoint 2010 Masterpage

查看:91
本文介绍了获取页面所有者的联系电子邮件并在SharePoint 2010母版页中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了具有多个母版页/页面布局的解决方案,作为一组SharePoint 2010发布网站集的功能.

I've built out a solution with multiple masterpages/page layouts as features for a set of SharePoint 2010 publishing site collections.

一个一致的请求是能够获取页面所有者的联系电子邮件并将其显示在母版页脚中.如果未输入页面联系人电子邮件",那么我需要从人员选取器"中获取页面所有者数据,然后从中获取联系人电子邮件.

One consistent request is to be able to grab the page owner contact email and display it in the footer of the masterpage. If the page Contact Email isn't entered, then I need to grab the page owner data from the People Picker, and grab the contact email from that.

我不想将每个发布页面布局都添加到我的解决方案中,而无需手动将联系人电子邮件"列添加到占位符中,这对我来说似乎很疯狂.我认为必须有一种方法可以从母版页中获取页面所有者数据,但我无法弄清楚.我开始研究jQuery SPServices库,但到目前为止,我也无法弄清楚它.

I don't want to have to add every single publishing page layout to my solution, and manually add the Contact Email column into a place holder, that seems crazy to me. I figure there has to be a way to grab the page owner data from within the masterpage, but I can't figure it out. I started looking at the jQuery SPServices library, but so far I haven't been able to figure it out there, either.

有人在使用母版页中提供的页面所有者联系信息添加联系人电子邮件方面有任何经验吗?

Does anyone have any experience in adding a contact email using the supplied page owner contact information in the Masterpage?

推荐答案

好,为了解决此问题,您需要jQuery 1.7.x +和您网站上安装的SPServices jQuery库 0.7.2或更高版本.

OK, in order to resolve this, you need jQuery 1.7.x+ and the SPServices jQuery library version 0.7.2 or greater installed on your site.

使用 GetListItems 作为SPServices的操作.

Use GetListItems as the operation from SPServices.

我要在Pages目录中搜索页面,所以listName是"Pages".

I'm searching for pages within the Pages directory, so listName is "Pages".

CAML视图字段基本上是PublishingContactEmail和PublishingContact的列.我发现使用 u2u的CAML构建器版本4.0.0.0

The CAML View Fields are basically the columns for PublishingContactEmail and PublishingContact. I found those using u2u's CAML builder version 4.0.0.0

ows_变量可以在Firebug中的POST对象的xml视图中找到.

The ows_ variables can be found in the xml view of the POST object in firebug.

ows_PublishingContact返回联系人信息的长字符串.幸运的是,电子邮件地址被,#包围,这使得将其拆分为一个数组然后搜索电子邮件@ @很容易,但这就是在那里的原因.

The ows_PublishingContact returns a long nasty string of the contact's information. Fortunately the email address is surrounded by ,#, which made splitting it into an array and then searching for an email @ easy, but that's why that's there.

function get_page_contact_email() {    
    var thisPageID = _spPageContextInfo.pageItemId;    
    var e;    
    $().SPServices({    
        operation: "GetListItems",    
        async: false,    
        listName: "Pages",    
        CAMLViewFields: "<ViewFields><FieldRef Name='PublishingContactEmail' /><FieldRef Name='PublishingContact' /></ViewFields>",    
        CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",    
        completefunc: function (xData, Status) {    
            $(xData.responseXML).SPFilterNode("z:row").each(function () {    
                if (thisPageID == $(this).attr("ows_ID")) {    
                    if ($(this).attr("ows_PublishingContactEmail")) { // if page email is set    
                        e = $(this).attr("ows_PublishingContactEmail");    
                    } else if ($(this).attr("ows_PublishingContact")) { //otherwise use contact info    
                        var contact = $(this).attr("ows_PublishingContact").split(",#");    
                        for (var c = 0; c < contact.length; c++) {    
                            if (contact[c].indexOf("@") != -1) {    
                                e = contact[c];    
                            }    
                        }    
                    } else { //or nothing is set.    
                        e = false;    
                    }    
                }    
            });    
        }    
    });    
    return e;    
}

这篇关于获取页面所有者的联系电子邮件并在SharePoint 2010母版页中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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