Is there a way in Sharepoint 2007 Publishing, to retrieve a custom content type's column value for the displayed article. I want to show different colored ribbon images according to article type which is stored in a custom column.

Thank you.

3 Answers 3


If you place a FieldValue control on a Page Layout you can set this to display the value of a custom column using the FieldName property. For example:

<SharePointWebControls:FieldValue FieldName="CustomFieldName" runat="server"/>

Note you will need a reference to Microsoft.SharePoint.WebControls at the top of the page before this will work e.g.

<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 

If you need to perform some manipulation on this value then you can get the value in code by using SPContext.Current.ListItem["CustomFieldName"].


For a publishing page to get the column value I use the following

This code i have written in a UserControl Placed in a Page Layout , and in the UserControl i wrote the following code

using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.Publishing.WebControls;
using Microsoft.SharePoint.Publishing.Fields;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;

 PublishingPage currentPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);

if (currentPage != null)

                    string title= currentPage.ListItem["Title"].ToString(); ;


I used the folowing method to get the data from all publishing pages that have value in the "Page Content" field

            using (SPSite site = new SPSite("[site collection url]"))
                using (SPWeb web = site.OpenWeb("/[Subsite]/"))
                    PublishingWeb myWeb = PublishingWeb.GetPublishingWeb(web);
                    PublishingPageCollection pages = myWeb.GetPublishingPages();

                    foreach (PublishingPage page in pages)

                        if (page.Title == pageTitle)
                            if (page.ListItem["Page Content"] != null)
                                    Label2.Text = page.ListItem["Page Content"].ToString();
                                    Label2.Text = "The page " + page.Title.ToString() + " does not have content in ...Page Content... section";


hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.