Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a Summary Link field and added it to a page layout and created a page based on this page layout. I have tried to add links to the summary link using powershell but the links do not appear. here is my code:

$web = get-spweb "http://siteurl"
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pagesListName = $pubWeb.PagesListName
$defaultAspxFile = $pubWeb.GetPublishingPage("$pagesListName/default.aspx")
$summaryLinkFieldValue = New-Object Microsoft.SharePoint.Publishing.Fields.SummaryLinkFieldValue

$groupLink = New-Object Microsoft.SharePoint.Publishing.SummaryLink("My group")
$groupLink.IsGroupHeader = $true 
$summaryLinkFieldValue.SummaryLinks.Add($groupLink)

$linkLink =  New-Object Microsoft.SharePoint.Publishing.SummaryLink("my link")
$linkLink.LinkUrl = "http://www.test.se"
$summaryLinkFieldValue.SummaryLinks.Add($linkLink)

#$defaultAspxFile.CheckOut()
$pageItem = $defaultAspxFile.ListItem

$pageItem[[Microsoft.SharePoint.Publishing.FieldId]::SummaryLinks] = $summaryLinkFieldValue
$defaultAspxFile.Update()
$web.Update()

when I check $pageItem[[Microsoft.SharePoint.Publishing.FieldId]::SummaryLinks] in powershell it contians the link but it does not appear on the page.

share|improve this question
    
You are not updating the pageItem, call pageItem.Update() –  Robert Lindgren Dec 6 '13 at 10:31
    
no it didn't help, I added it –  Medes Dec 6 '13 at 11:03

1 Answer 1

You must publish and approve the page:

$page = $defaultAspxFile.ListItem.File
$page.Publish("")
$page.Approve("")
share|improve this answer
    
It didn't solve the problem either. –  Medes Dec 6 '13 at 12:16

Your Answer

 
discard

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.