Thursday, July 26, 2007

Display CSS Classes within SharePoint

I'm posting this just because I'm getting tired of losing the script... This is a great script written by Microsoft to reveal CSS classes within SharePoint.


Taken from: (http://msdn2.microsoft.com/en-us/library/ms438349.aspx)


<script language="jscript">
function ClassInfo()
{
    if (window.event.srcElement.className != null)
    {
        stsclass.innerText = window.event.srcElement.className;
    }
    else
    {
        stsclass.innerText = "";
    }
}
 
window.document.body.onmouseover = ClassInfo;</script>
 
<div style="border-style:solid;border-width:1px; width: 281px; height: 34px;
position: absolute; left: 286px; top: 41px; z-index:15; padding-left:4px;
padding-right:4px; padding-top:2px; padding-bottom:2px; background-color:#EEEEF4">
<p id="stsclasstitle"><font face="Tahoma" id="stsclasstitle">Classname: </font>
<font face="Tahoma"id="stsclass">&#xa0;</font>
</p></div>


Microsoft mentions including this within a ASPX page.  Why mess with that?  Just create a content editor web part, open the source editor, and paste the above code in.



You will notice that the CSS codes now appear in the top middle-left of the screen as you scroll over the SharePoint page.



If you wish to change the location of the box displaying the codes just alter the following to suite your needs: position: absolute; left: 286px; top: 41px; z-index:15


The following example shows it changed to: position: absolute; left: 100px; top: 0px; z-index:15



This will help to alleviate some of the branding stress when you are ready to pull your hair out.  Always remember to check Heather Solomon's GREAT CSS Reference Chart as well: http://www.heathersolomon.com/content/sp07cssreference.htm


 

Creating a New Document Template

When multiple content types are used, Document Templates are managed one per content type.  The following steps walk through uploading a new document template for a content type and assigning it to a document library.



  1. Go to Site Actions Site Settings Modify All Site Settings.

  2. Click on Site Content Types under Galleries.

  3. Click on the Content Type that is to be changed.

  4. Click on Advanced Settings under Settings.

  5. Choose to upload a new document template and browse out and select the file.  Click Ok to save changes.
    Step 5

  6. If the content type has not been added to the document library, browse to the Document Library where the Content Type will be used and go to the settings of the library.
    Step 6

  7. Select to Add from existing site content types under Content Types.
    Step 7

  8. Add the content type and click Ok.
    Step 8

  9. Browse back to the document library.  The new document template associated with the added content type now appears under the New Button.
    Step 9

 

Delete Files with Workflow Using Duration

This is just a quick little tidbit.  Out-of-Box workflows in MOSS, unless manually kicked off, require an event to be triggered.  I was trying to figure out a way to automatically delete files from a document library 3 days after they were uploaded.  The doc library was being used strictly as a transfer point and needed to be kept clean.  Thanks to Sean S. for the idea...


So as simple as it is:


1.       Start a new workflow using SharePoint Designer by going to File -> New -> Workflow.


2.       Give the Workflow a name and select the target doc library or list.



3.       Set the start event.  I set mine to automatically start when the item is created or changed.  Click Next.


4.       Enter a name for Step 1 such as `Pause for 3 days'


5.       Do not select a condition because we want it applied to all items.


6.       Under Actions select `Pause for duration'.



7.       Change to 3 days, 0 hours, and 0 minutes.



8.       On the right choose to `Add workflow step'


9.       Once again, give the step a name and no condition.



10.   Select Delete Item under Actions and set it to Current Item.


11.   Click Finish to save the workflow.


NOTE: A good way to test this first is to set the duration to a low count like 1 minute.  Once you are sure it works properly, set it to your desired time frame.