Tuesday, April 24, 2012

PowerShell Update Publishing Page Properties

Here is the simple powershell script to update the Publishing Pages properties. The web url and list name is read from the user.
#Declare variables

#Read web site url
$Url=Read-Host "Enter a web site url"

#Read list name
$ListName=Read-Host "Enter list name"

$FieldInternalName = "ArticleSortOrder"
$comment = "Added article sort order"

#Get web, list objects
$web = Get-SPWeb -Identity $Url
$spList = $web.Lists[$ListName]
 write-host $ListName" list doesn't exist"

if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) 
 write-host "Reviewing pages in"$web.Title"site...."
 #Get the Publishing Web and pages within it
 $publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
 $publishingPages = $publishingWeb.GetPublishingPages()
 foreach ($publishingPage in $publishingPages)
  $file = $web.GetFile($publishingPage.Uri.ToString())

  [Microsoft.SharePoint.SPListItem]$spListItem = $file.Item
  $FieldValue = $spListItem[$FieldInternalName]
  if(!$FieldValue -or $FieldValue -eq 0)
   $FieldValue = 9999
   Write-Host "Checking out page: " $publishingPage.Title
   Write-Host "Updating`t" $spListItem.Name "`tArticleSortOrder to $FieldValue"
   $spListItem[$FieldInternalName] = $FieldValue

   $file.CheckIn($comment, [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn)        
   write-host "Added article sort order and checked in file: " $publishingPage.Title "`n"
    #Notify user that the site is not a publishing site
    write-host $web.Title"is not a publishing site"

Monday, April 9, 2012

HTML Double Click Event

This morning i am surprised when i came to know html control does have a event called ondblclick for double click event. I know it is new for most of the html developers though they have extensive knowledge.

I feel its really useful for double click functionality.

<a  ondblclick="javascript:alert('double click event')">double click</a>