Friday, October 30, 2009

Add Web Part inside a Master Page in MOSS 2007

Add Web Part inside a Master Page in MOSS 2007


Imagine that you are designing a master page for your MOSS site and you have a requirement to have a functionality that is not possible out of the box. You brain storm on it and concludes that only custom web part can solve your problem.
But now your concern is how you can make this custom web part as part of your master page?
It’s easy! Just follow the steps given below to add a web part inside a master page.


1. Deploy the web part in your web application as you do normally.
2. Check whether the web part is showing up in the web part gallery.
3. Create a web part page by navigating to the site settings, create web part page.
4. Add your custom web part on the web part page.
5. Start SharePoint designer and open the newly created web part page.
6. You will now find two entries corresponding to the web part you added on the page
i. In the page declaration you will find a entry which looks something like this:


<@ Register TagPrefix="WpNs0" Namespace="MyNamespace.MyClass" Assembly=" MyNamespace.MyClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">



ii. Click on the web part section in the page and you will see an entry like this:


WpNs0:WebPartName runat="server" ID="g_34cdbb90_38c6_4561_9182_8fbc0d2423a6" ExportMode="All" Title="WebPartTitle"


7. Copy these entries in separate notepad, and close the page opened in the SharePoint designer.
8. Now open the master page in SharePoint designer and add the first entry in the declaration section and second entry at the place where you want to add the web part to.
9. Save the page, check in and publish it and that’s it. Your job is done.



Monday, October 26, 2009

Time to Certificate!


Have any of you noticed how hot SharePoint products and technologies have become over the past year or so. According to industry sources, sales of SharePoint will top $1 billion this year alone. For our purposes, we must ask the question: "What SharePoint certifications are available, and how can I earn 'em as quickly as possible?"
As of this writing, there exist two Microsoft Certified Technical Specialist (MCTS) tracks for SharePoint Products and Technologies

Administration
Development
    I am quite sure that Microsoft will eventually offer a premium Microsoft Certified IT PRofessional (MCITP) credential for each SharePoint specialty track.
    SharePoint Administration Track
    To earn your MCTS in Windows SharePoint Services 3.0 Configuration, you must pass the following exam:
    To earn your MCTS in Microsoft Office SharePoint Server (MOSS) 2007 Configuration, you must pass the following exam:
    SharePoint Development Track
    To earn your MCTS in Windows SharePoint Services 3.0 Application Development, you must pass the following exam:
    To earn your MCTS in Microsoft Office SharePoint Server 2007 Application Development, you must pass the following exam:
    Remember that, at least as of this writing, Microsoft has an exclusive partner agreement withPrometric. Therefore, you cannot register to take a Microsoft exam with Pearson VUE.
    If any of you have taken a Microsoft certification exam, you already know that "merely" possessing subject matter expertise is only half of the battle. That is to say, you must also hone your test-taking skills.
    Test-Prep Resources
    With regard to SharePoint study books, of course I am going to recommend that you subscribe to Safari Books Online and see what you can find.
    Outside of Safari, most or all of the SharePoint titles from Microsoft Press are outstanding. What I particularly admire about MS Press books over the past few years is their trend to contract real-world industry experts as authors instead of internal marketing folks.
    With respect to computer-based training, I would suggest TranscenderBoson, or ExamForce.
    Please let me know if you have any questions by leaving your thoughts in the comments portion of this post. I am happy to help in any way that I can.

    Thursday, October 22, 2009

    Adding External Javascript files into SharePoint



    WSS 3.0 keeps all of it's external script files in 12/Templates/Layouts/1033. This localized managed path hosts common file such as"core.js" and other external resources. It's becoming a common task to include custom JavaScript in SharePoint pages that is registered. One of the "nifty" controls that WSS 3.0 offers is the SharePoint ScriptLink control (< SharePoint:Link />), this control allows a developer to link to external script file living in the localized managed path. Here's a practical example that should shed some light on the subject:

    1.) Include the following in an external javascript file named "Superman.js".


    document.write("I am the night.");


    2.) Copy "Superman.js" to 12/Templates/Layouts/1033.

    3.) Now add the following control to the head of your masterpage:

    < SharePoint:Link ID="Batman" language="javascript" name="Superman.js" />


    That's it! Just upload the masterpage into the masterpages gallery and you should see "I am the night" printed on your pages every time they load. This control will become very useful when you begin to use new technologies like "Silverlight" or integrating the "oh so holy" Flash into SharePoint. 

    Enjoy! :)

    Wednesday, October 21, 2009

    Sharepoint Inline!



    I am often asked to customize the layout of a page within a SharePoint site as a “one-off” change (one that affects only that page and not the entire SharePoint site).  This is typically a request to hide something on the page or to change the attributes of a font on a page, such as hiding the quick launch bar, hide the breadcrumbs or increasing the font on a header.  These changes are often small and don’t necessarily require a change to the site master page or style sheet (.css file).  One of my favorite tips is to use “inline CSS styles” to apply style changes to a page.
    My solution basically consists of adding a Content Editor web part to a page and including style sheet instructions that override the current page styling (as HTML style tags within the Content Editor web part).  The beauty of this solution is that it does not require changes to the site style sheet and can be isolated to just one page.  The down-side to this approach is that the change only impacts one page at a time, and you must apply this technique for each page you wish to change.
    In this article I will provide you the specific instructions needed to inline CSS styles to customize your pages.

    Example Request: Hide the breadcrumb on our news article page.

    Let’s pretend we’ve received a request to hide the breadcrumb line so that the page title is at the top of the page.  The user is basically asking us to make remove the words “Home > News > Sample News Article” and make the words “Sample News Article” appear at the top of the page.
    blogpost1

     

    Step 1: Add a Content Editor web part to the page and make it hidden.

    Open the page in edit mode and add a web part to the page of type “Content Editor web part”.  You do this by using the “Site Actions” menu and selecting “Edit Page”.  Modify the properties of the web part so that the web part is hidden.  You do this by checking the “Hidden” box inside the Layout section of the web part settings panel.  Important note: Even though you’ve hidden the web part the CSS styles still effect the contents of the page.
    blogpost2

     

    Step 2: Identify the styles to override in the HTML source of the page.

    Open the HTML source of the page and look through the HTML for the area you want to effect.  Both Internet Explorer and Firefox provide a menu option for viewing the HTML source for a page; in Internet Explorer you’ll need to use the View menu and select Source.  After opening the HTML source you can search for the desired HTML area, In our case we can do a find on “Sample News Article” to find the breadcrumb area.  See the following code example; notice the CSS class named “breadcrumb” that is applied to the HTML “div” tag, we will be applying a change to the “breadcrumb” class to override the styling of the breadcrumb text.
    <div class="breadcrumb">
        <span id="ctl00_PlaceHolderTitleBreadcrumb_siteMapPath">
        <span><a class="ms-sitemapdirectional" href="/Pages/Default.aspx">Homea>span>
        <span> > span>
        <span><a title="Company News Home" class="ms-sitemapdirectional" href="/News/Pages/Default.aspx">Newsa>span>
        <span> > span><span class="breadcrumbCurrent">Sample News Articlespan>span>
    div> 

    Step 3: Use the HTML Editor to add style tags to override the page styles.

    Open the Content Editor web part and use the “Source Editor” button to add HTML directly into your page.  Enter your CSS commands in the middle of tags.  See the example below where we override the breadcrumb div tag by using the CSS display property to hide the breadcrumb div.
    blogpost3
     blogpost4
    <p> p>
    <style type="text/css">
        div.breadcrumb
        {
            display: none;
        }
    style> 

     

    Step 4: Preview the page and make adjustments if necessary.

    Save the changes to the Content Editor web part and publish your changes.  Be sure to preview the page to see if the CSS style overrides you applied are what you expected.  If not, you’ll need to back up a few steps and try again.
    plogpost5

    My hope is that this technique of applying inline CSS styles directly into your SharePoint pages can give you another option for formatting your pages.  Again, this technique can be particularly useful when you have a change that affects only a single page and does not need to affect the entire SharePoint site.  Good luck and let me know if you come up with other creative uses for applying inline CSS styles.