Tuesday, 8 September 2009

Content Editor Web Part Tricks

1)Apply the styles dynamically using Content Editor Web part

I got a requirement, which needs to update the style dynamically on the page load for a specific tool bar item in the LIVE environment.
As the time we have is very limited, I thought of using java script to apply the required style.

Steps to achieve this

1. Added the Content Editor Web Part to the page
2. Added the following script
<script type = "text/javascript">
document.getElementById('[Id of tool bar Item]').style.background = "#BADDAD";

</script >
3. Content Editor web part is hidden.

Cheers we are done!.


2) Create a Upload Multiple Files Control using CEWP

Refer this for using Content Editor Web part for uploading Multiple Documents into your desired library


3)Display your outlook emails using CEWP
With the following script you can access the Outlook Inbox from Content Editor Web part

1) Add Content Editor Web part to the page
2) Add the following code into the webpart

<object classid="clsid:0006F063-0000-0000-C000-000000000046"
id="ViewCtlFolder" width="100%" height="200"
<param name="Namespace" value="MAPI">
<param name="Folder" value="Inbox">//(you can replace this Inbox value with your required folder in Outlook box)
<param name="Restriction" value="">
<param name="DeferUpdate" value="0">

3) Click OK to see your outlook mails getting displayed in your page.
This needs outlook to be available on the box,where this page is being viewed.


4) Display the Flash files in Sharepoint Pages

1) Upload the desired Flash File to the Image Library and ensure that its approved

2) Add the Content Editor Web part to the required page in Portal.

3) Click on the webpart menu to open the tool part and click on "Source Editor"

4) Paste the following code
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="320" HEIGHT="240" id="Yourfilename" ALIGN="">
<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#333399>
<EMBED src="FLASHFILENAMEWITHPATH.swf" quality=high bgcolor=#333399 WIDTH="320" HEIGHT="240" NAME="Yourfilename"
ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">

5) Fill the values of "FLASHFILENAMEWITHPATH.swf" with your flash file path from step 1.

6) Click on "OK"

Then the flash file would be displayed.


Happy SPD'ing

No comments: