Notes eMeroo(Some TechTips);

January 17, 2012

Shared Notes

Filed under: Misc,SharePoint — Amira @ 1:15 pm

SharePoint 2010

SharePoint 2007 — MOSS

Visual Studio:

  • Get Public Key Token for a Strong Named Assembly
    Tools –> External Tools.. –> Add
    Title: Get SN Token
    Command: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sn.exe  || C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe
    Arguments: -Tp $(TargetPath)
    Check Use Output Window

Web

http://www.webmarketingnow.com/tips/meta-tags-meta-expires.html

December 27, 2008

Branding and customizing EditControlBlock(ECB)

Filed under: SharePoint — Amira @ 7:45 pm

Branding sharepoint Site is one of the problems that you may face while working with MOSS 2007.
Simply you can build a feature to customize the most of sharepoint menus, by working with the ElementManifest file say “elements.xml”.
Here’s the
Default Custom Action Locations and IDs that will help in customizing menus, and this topic illustrates How to: Add Actions to the User Interface .

This topic will illustrate another branch of branding sharepoint, which is customizing context menu in Document Library. You can add item to this context menu by following the way that is illustrated in the previous links. You will use the location of “EditControlBlock”. But if you target an advanced actions for example adding sub context menu to one of the main context menues, you should follow this topic.

Problem:
I need to add sub context menu named (Document Library) to “Send To” menu, and add items to Document Library. as shown below

CustomContextMenu


Solution:
The workaround of this problem is editing at JavaScript file of MOSS located @ “Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033”.

Step1: You will go to this function AddSendSubMenu(m,ctx) at CORE.JS, where
m is the menu object.
ctx provides HTTP context information about the web request.

Step2: and after those two lines

1:      var sm=CASubM(m,strDisplayText,"","",400);
2:      sm.id="ID_Send";
@Line 1: define sm which instructs to add strDisplayText to m, where
            - strDisplayText: is now assigned to “Send To”
            - m: is representing the main Context Menu

Step3: Start writing this JavaScript code snippet 
   1: //start override
   2:
   3:         //add "Document Library" item to "Send To"
   4:         var L_DocumentLibrary_Text="Document Library";
   5:         strDisplayText =L_DocumentLibrary_Text;
   6:         var docLib=CASubM(sm,strDisplayText,"","",400);
   7:         docLib.id="id_L_DocumentLibrary_Text";
   8:
   9:         var Const_DocLibs_Array=["DocLib1","DocLib2"];
  10:
  11:         //add all document ibraries exists to "Document Library" Menu
  12:         for(var cnt=0;cnt<Const_DocLibs_Array.length;cnt++)
  13:         {
  14:         var L_Doc_Text=Const_DocLibs_Array[cnt];
  15:         strDisplayText=L_Doc_Text;
  16:         strAction= "STSNavigate('"+                ctx.HttpRoot+                "/_layouts/SendToDoc.aspx" + "')";
  17:         strImagePath=ctx.imagesPath+"existingLocations.gif";
  18:         menuOption=CAMOpt(docLib,strDisplayText,strAction,strImagePath);
  19:         menuOption.id="id_"+L_Doc_Text;
  20:         }
  21:     //end override
Inside AddSendSubMenu you can add sub items or menus to “Send To”.

@Line 6: define docLib which instructs to add strDisplayText to sm, where
             - strDisplayText: is now assigned to “Document Library”.
             - sm: is representing “Send To” menu, as descriped @ setp2.
@Line 9: define an array of the sub menu items of “Document Libray”.
@Line 15: reassign strDisplayText to new name represents text defined in array.
@Line 16: define the action of each item.
@Line 17: assign strImagePath to the image that represents each menu item.
@Line 18:  call CAMOpt to assign the action (strAction) to each item (strDisplayText) at the menu (docLib). 

Conclusion:
* Use the function CASubM(menuObject,strDisplayText,“”,“”,400) to add a menu.
* Use the function CAMOpt(menuObject,strDisplayText,strAction,strImagePath) to assign an action to item of a menu.

P.S. Here is some variables at Core.js which is defined while you are in a document Library

  • ctx.HttpRoot –> http://amira-pc/NewSite
  • ctx.ListTitle –> Shared Documents
  • ctx.listBaseType –> 1
  • ctx.listTemplate –> 101
  • ctx.listName—> {63BAFD2F-6478-45B1-B487-D454470ED346}
  • ctx.view—> {FE013DBB-809C-478D-922A-5DE78471F78E}
  • ctx.listUrlDir—> /NewSite/Shared Documents
  • ctx.HttpPath—> /NewSite/_vti_bin/owssvr.dll?CS=65001
  • ctx.displayFormUrl—> /NewSite/Shared Documents/Forms/DispForm.aspx
  • ctx.editFormUrl—> /NewSite/Shared Documents/Forms/EditForm.aspx
  • currentItemCanModify –> true
  • ctx.imagesPath—> /_layouts/images/
  • originalFormAction —> display current view page (AllItems.aspx or any custom view)

,and While the context menu of a specific item is opened,

  • currentItemAppName –> Microsoft Office Word
  • currentItemFileUrl –> /NewSite/Shared Documents/New Microsoft Office Word Document.docx
  • currentItemIcon –> icdocx.gif
  • currentItemID –> 24
  • currentItemUrl –> /NewSite/Shared Documents/New Microsoft Office Word Document.docx

Guide while branding and customizing menu
Add FireBug Blug-in to your FireFox and follow DOM values to get the rest of variables’ value of core.js at any area of sharepoint.

Hope this helps Smile

Amira

Create a free website or blog at WordPress.com.