Monday, April 11, 2016

Regular expression for Culture Code

/^[a-z]{2,3}(?:-[A-Z]{2,3}(?:-[a-zA-Z]{4})?)?$/
Here is how it works
^       <- Starts with
[a-z]   <- From a to z (lower-case)
{2,3}   <- Repeated at least 2 times, at most 3
(?:     <- Non capturing group
   -        <- The "-" character
   [A-Z]     <- From a to z (upper-case)
   {2,3}     <- Repeated at least 2 times, at most 3
   (?:       <- Non capturing group
       -         <- The "-" character
       [a-zA-Z]  <- from a to Z (case insensitive)
       {4}      <- Repeated 4 times
   )         <- End of the group
   ?         <- Facultative
 )       <- End of the group
 ?       <- Facultative
 $       <- Ends here

SPField.Type property & FEW ENUMERATION & LINKS

Change Column Type in SharePoint List using PowerShell

param(
[String]$ConfigPath = $(throw "Configuration object required to execute script."),
[String]$LocalesPath = $(throw "Settings object required to execute script.")
)
#################################################################################

$configSettings = New-Object -TypeName XML
$configSettings.Load($ConfigPath)

$localeSettings = New-Object -TypeName XML
$localeSettings.Load($LocalesPath)


##Script to run : .\Update-EventContentType.ps1 -ConfigPath "Full Path Configuration File" -LocalesPath "Full Path of Settings File"


function Update-FieldVideo {
    param(
   [string] $SiteUrl
    )
$site = Get-SPSite $SiteUrl
$web = $site.RootWeb

        $ct = $site.RootWeb.ContentTypes["Intranet Video News"]
write-Host "content Type Found"  -foregroundcolor green
write-Host "Update Field Display Name Start"  -foregroundcolor green

        $location = $ct.FieldLinks["IntranetVideoText2"]
        $location.Type = [Microsoft.SharePoint.SPFieldType]::Note

$desc = $ct.FieldLinks["IntranetVideoText1"]
        $desc.Type = [Microsoft.SharePoint.SPFieldType]::Note //FOR THIS PART CHECK ANOTHER ARTICLE FOR FIELD TYPE IN POWERSHELL

$ct.Update($true)

write-Host "Update Field Display Name End"  -foregroundcolor green
}


foreach ($sc in $configSettings.Config.SiteCollections.ChildNodes) {

    if($sc.IsRootHNSC -ne "true"){
        $SiteUrl = "{0}/{1}/{2}" -f $localeSettings.Settings.HNSC_HostHeader,$localeSettings.Settings.HNSC_ManagedPath,$sc.SiteUrl
#Update-FieldList -SiteUrl $SiteUrl
#Update-FieldOrder -SiteUrl $SiteUrl
#Update-contentTypeList -SiteUrl $SiteUrl
Update-FieldVideo -SiteUrl $SiteUrl
       }
}

Monday, April 4, 2016

SharePoint Field TYPE for Elements.xml

Single Line of Text:
field id=”{FDDC4E38-25E0-4FD9-92E7-D17F34A5AB12}” description=”My Content ID of Item” staticname=”ContentID” name=”ContentID” displayname=”ContentID” type=”Text” group=”Sample Site Columns” sourceid=”http://schemas.microsoft.com/sharepoint/v3&#8243;
Number:
Field ID=”{13b3652a-d543-465d-91cb-a9d625637855}” StaticName=”Read_Times” Name =”Read_Times” DisplayName =”Read_Times” Description=”Read Time count of Item” Type=”Number” Group =”Sample Site Columns” SourceID =”http://schemas.microsoft.com/sharepoint/v3&#8243;
Date Time:
Field ID=”{d076e4d5-c785-4c04-8b56-c1f021721749}” StaticName=”CreateDate” Name=”CreateDate” DisplayName=”Create_Date” Description=”Create Date of Item” Group=”Sample Site Columns” Type=”DateTime” Format=”DateOnly” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221;
Multiple lines of text:
Field ID=”{2ae59f08-0fb0-4a9c-8a31-a180161b1029}” StaticName=”PublisherDescription” Name=”PublisherDescription” Description=”Publisher Description of Item” DisplayName=”Publisher_Description” Type=”Note” RichText=”FALSE” NumLines=”6″ Group=”Sample Site Columns” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221;
Rich Text HTML:
Field ID=”{13cd0291-df15-4278-9894-630913e4d2b9}” StaticName=”AccrediterDescription” Name=”AccrediterDescription” DisplayName=”Accrediter_Description” Description=”Accrediter Description of Item” Type=”Note” NumLines=”6″ RichText=”TRUE” RichTextMode=”FullHtml” Group=”Sample Site Columns” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221;
Publishing HTML:
Field ID=”{E2CC0231-FA6C-4F90-839C-118C304DFCF1}” StaticName=”PMediaDescription” Name=”PMediaDescription” DisplayName=”MediaDescription” Type=”HTML” RichText=”TRUE” RichTextMode=”ThemeHtml” Group=”Site Columns” SourceID=”http://schemas.microsoft.com/sharepoint/v3&#8243; UnlimitedLengthInDocumentLibrary =”TRUE”
Publishing Image:
field id=”{148e8191-afe7-4422-b1d1-7202eda667f1}” description=”Image 1 link of Item” staticname=”PImageID1″ name=”PImageID1″ displayname=”Image_ID1″ type=”Image” group=”My Site Columns” sourceid=”http://schemas.microsoft.com/sharepoint/v3&#8243; richtext=”TRUE” richtextmode=”ThemeHtml”>
HyperLink & Image:
Field ID=”{635a2031-2088-4413-b54e-d2af5daf08bf}” StaticName=”ImageAuthor” Name=”ImageAuthor” DisplayName=”Image_Author” Description=”Author Image” Type=”URL” Format=”Image” Group=”Sample Site Columns” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221;
YES/No Boolean:
<Field ID=”{11018312-58f9-4eb0-867d-71298f82d98d}” Name=”isActive” StaticName=”isActive” DisplayName=”isActive” Description=”Select if Item is Active” Group=”Sample Site Columns” SourceID=”http://schemas.microsoft.com/sharepoint/v3&#8243; Type=”Boolean”&gt;
<default>0</default>
</FIELD>
CHOICES:
<Field ID=”{67f8faa4-e3ee-44bf-a3b4-6e7fc9c6b9fe}” Name=”Market” StaticName=”Market” DisplayName=”Market” Description=”Market of the Country” Group=”Sample Site Columns” SourceID=”http://schemas.microsoft.com/sharepoint/v3&#8243; Type=”Choice”&gt;
<choices>
choice>Gold</choice
</choices>
</FIELD>
MultiSelect:
<Field Type=”MultiChoice” DisplayName=”Labels_Selected” FillInChoice=”FALSE” Group=”Sample Site Columns” ID=”{2fdf0ba7-0052-4e9f-80f6-e7669ac4ae4f}” SourceID=”http://schemas.microsoft.com/sharepoint/v3&#8243; StaticName=”LabelsSelected” Name=”LabelsSelected”&gt;
</FIELD>
Lookup Columns:
Field Type=”Lookup” ID=”{FE45AC76-C0E2-46C8-A047-E8C43C10315C}” Name=”LU_Country” StaticName=”LU_Country” DisplayName=”LU_Country” Required=”FALSE” List=”Lists/Region Country Master” ShowField=”RollOutCountry” UnlimitedLengthInDocumentLibrary=”FALSE” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221; Group=”Sample Site Columns”
Multi Lookup Columns:
Field Type=”LookupMulti” Mult=”TRUE” ID=”{85062ACF-315B-460A-B756-2230A5FE082F}” Name=”LU_Language” StaticName=”LU_Language” DisplayName=”LU_Language” Required=”FALSE” List=”Lists/Language Master” ShowField=”Title” UnlimitedLengthInDocumentLibrary=”FALSE” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221; Group=”Sample Site Columns”
Lookup with Additional Field Lookup column:
Field Type=”Lookup” ID=”{9AA2985D-AA17-4EA2-9556-9B0E112A64F6}” Name=”LU_ApplicationType” StaticName=”LU_ApplicationType” DisplayName=”LU_ApplicationType” Required=”FALSE” List=”Lists/Application Type” ShowField=”ApplicationType” UnlimitedLengthInDocumentLibrary=”FALSE” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221; Group=”Sample Site Columns”
Field Type=”Lookup” ID=”{668D51C4-804D-43E7-8211-950AE3BCD9A3}” Name=”LU_ApplicationType_ID” StaticName=”LU_ApplicationType_ID” DisplayName=”LU_ApplicationType_ID” List=”Lists/Application Type” ShowField=”ApplicationTypeID” FieldRef=”9AA2985D-AA17-4EA2-9556-9B0E112A64F6″ ReadOnly=”TRUE” UnlimitedLengthInDocumentLibrary=”FALSE” SourceID=”http://schemas.microsoft.com/sharepoint/v3/fields&#8221; Group=”Sample Site Columns”
User column
<Field ID=”{080FF274-4FAB-43c9-9710-78F3A76925DC}” Type=”User”DisplayName=”My User” StaticName=”MyUser” Name=”User” Required=”TRUE” UserSelectionMode=”PeopleOnly” ShowField=”Name” ></Field>

Monday, December 22, 2014

In Content editor webpart , Image Rotation at the time of page refreshing


<div id="mainarea"><!-- Start Featured Items -->
<div class="cta cta_featured f0">

target="_blank"><img src="/EN/Documents/images/GlobalInnovators_2.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f1" style="display: none;">
                <a href="http://www.latimes.com/business/realestate/la-fi-robinsons-asian-

investors-20140912-story.html" target="_blank"><img src="/EN/Documents/images/Asian-

Capital.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f2" style="display: none;">
                <a href="/EN/aboutus/MediaCentre/2014/Pages/Euromoney-2014.aspx"><img

src="/EN/Documents/images/Euromoney-Awards-2014.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f3" style="display: none;">
                <a href="/EN/aboutus/corporateresponsibility/Pages/default.aspx"><img

src="/EN/Documents/images/2013-corporate-responsibility.jpg" alt=""/></a>
</div>

<div class="cta cta_featured f4" style="display: none;">
                <a href="http://annualreport.cbre.com/"><img src="/EN/Documents/images/Annual-

Report.jpg" alt=""/></a>
</div>
<!-- End Featured Items -->

<script>
(function() {

                // Begin Featured randomizing/cycling section
                function createCookie(name, value, days) {
                                if (days) {
                                                var date = new Date();
                                                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                                                var expires = "; expires=" + date.toGMTString();
                                }
                                else var expires = "";
                                document.cookie = name + "=" + value+expires + "; path=/";
                }

                function readCookie(name) {
                                var nameEQ = name + "=",
                                                ca = document.cookie.split(';');
                                for(var i = 0; i < ca.length; i += 1) {
                                                var c = ca[i];
                                                while (c.charAt(0)==' ') {
                                                                c = c.substring(1,c.length);
                                                }
                                                if (c.indexOf(nameEQ) == 0) {
                                                                return c.substring(nameEQ.length,c.length);
                                                }
                                }
                                return null;
                }

                function eraseCookie(name) {
                                createCookie(name,"",-1);
                }
               
                function itemCyclerRandomizer($collection, cookieName) {
                                var len = $collection.length,
                                                rand = Math.floor(Math.random() * len),
                                                lastItem = parseInt(readCookie(cookieName));

                                if (lastItem !== lastItem) { // true if NaN, which means no cookie
                                                lastItem = rand;
                                } else {
                                                if (lastItem >= len - 1) {
                                                                lastItem = 0;
                                                } else {
                                                                lastItem += 1;
                                                }
                                }

                                createCookie(cookieName, lastItem);

                                $($collection.get(lastItem)).show();
                               
                }
               
                itemCyclerRandomizer($('.cta_featured'), 'lastFeatured');
                itemCyclerRandomizer($('.cta_news .item'), 'lastNews');
                itemCyclerRandomizer($('.cta_case-study .item'), 'lastCaseStudy');
                // End Featured randomizing/cycling section
               
                // Click functionality for world office location dropdown
                $("#mapCtaLink").click(function() {
                                openWorldMenu();
                                $('html, body').animate({
                                                scrollTop: $("#world_office_menu").offset().top
                                }, 1000);
                });
               
                // Add class to fix IE8 nth-child support
                $('.cta_x2:nth-child(2n+2), .cta_x3:nth-child(3n+3)').addClass('row-end');
}());

$( document ).ready(function() {
    // alert("hi");
    $(".cta cta_featured f0").show();
});

</script>

Wednesday, November 5, 2014

EDIT global.ascx

<script runat="server">


    void Application_BeginRequest(object sender, EventArgs e)
    {

        if (HttpContext.Current.Request.RawUrl.Contains("/_layouts/mngsiteadmin.aspx"))
        {
            //Response.Redirect("/_layouts/copy_mngsiteadmin.aspx");
            Response.Redirect(HttpContext.Current.Request.RawUrl.Remove(HttpContext.Current.Request.RawUrl.LastIndexOf("/")) + "/custom/HTMLPage1.htm");
        }
    }
  </script>

Steps - HTTPModule to redirect mngsiteadmin.aspx page


  1. Open vsual studio
  2. Create a class library project
  3. add system.web reference
  4. inherit IHttpModule
  5. Put the code below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace ModuleHttp
{
    public class ModuleRedirect1 : IHttpModule
    {
        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }
        void context_BeginRequest(object sender, EventArgs e)
        {
            // throw new Exception("The method or operation is not implemented.");
            HttpApplication oApp = (HttpApplication)sender;
            if (oApp.Request.RawUrl.Contains("/_layouts/mngsiteadmin.aspx"))
            {
                oApp.Response.Redirect(oApp.Request.RawUrl.Remove(oApp.Request.RawUrl.LastIndexOf("/")) + "/copy_mngsiteadmin.aspx");
            }
        }
        public void Dispose()
        {
        }
    }
}

6. deploy the code
7. put the code in assembly / GAC

8. add reference to web.config under <modules runAllManagedModulesForAllRequests="true">

<add name='MyHttpModule' type='ModuleHttp.ModuleRedirect1,ModuleHttp,Version=1.0.0.0,Culture=neutral, PublicKeyToken=f2b9e495ae2296c1' />

<add name='ANY NAME' type='NAMESPACE.CLASSNAME,NAMESPACE,Version=1.0.0.0,Culture=neutral, PublicKeyToken=f2b9e495ae2296c1' />

9. MOST IMPORTANT - DO IISRESET . changes may not reflect else.