SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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"].

share|improve this answer

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(); ;

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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