in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

echef

From the cluttered (and clustered) brain of Josef Nielsen... A great place for Food, Friends, and... uh... SharePoint of course!

December 2007 - Posts

  • Adding category titles to Blog sites (category.aspx)

    I recently found an application of the Blog template that was a great fit, but needed the Category title listed on the top of the page when you click a category from the default page.  Normally, it is not visible anywhere except in the URL as a parameter, and in the categories of the posts listed. 

    The primary content of the page is displayed by a ListViewWebPart embedded in a table in the aspx file.  It starts like this:

    <table cellpadding=0 cellspacing=0 style='padding: 5px 10px 10px 10px;'>
               <tr>
                <td valign=top>
                    <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left" Title="loc:Left"><ZoneTemplate>
    <WebPartPages:ListViewWebPart runat="server" __MarkupType="xmlmarkup" WebPart="true" __WebPartId="{973762DE-3C5C-47B0-B80C-895B16BEDD6E}" >
    <WebPart xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
      <Title>Posts</Title>
      <FrameType>None</FrameType>
      <Description>Use the Posts list for posts in this blog.</Description>

    I added the following table row to the table above (before the webpart's row) to display it.

               <tr>
                <td><script language="javascript">
    function getURLParam()
        {
            var strReturn = "null";
              var strHref = window.location.href;
            if ( strHref.indexOf("?") > -1 )
            {
                var strQueryString = strHref.substr(strHref.indexOf("?")+1);
                var aQueryString = strQueryString.split("&");
                for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
                {
                  if (aQueryString[iParam].indexOf("Name=") > -1 )
                  {
                    var aParam = aQueryString[iParam].split("=");
                    strReturn = aParam[1];
                    break;
                  }
                }
                var fields,i;
                  fields = document.getElementsByTagName('DIV');
                  for( i = 0; i < fields.length; i ++ )
                  {
                    if(fields[i ].innerHTML.indexOf("::") != -1)
                    {
                         fields[i ].innerHTML = unescape(strReturn);
                    }         
                }
             }
        }
        _spBodyOnLoadFunctionNames.push("getURLParam");
                </script>
                 <div class="ms-sitetitle">::</div></td>
               </tr>

    Note the use of the _spBodyOnLoadFunctionNames.push method to fire the script... This is documented on the SPD team's blog here.  This is so you can embed your javascript in master or aspx and have it execute correctly once the entire page is loaded.  I probably could have gotten away without it here, but used it to be safe. 

    The script basically just looks for the <DIV> tag containing "::" and replaces it with the unescaped text from the "Name" parameter in the URL (Looks like http://MySharePointServer/sites/ICS/blog/category.aspx?Name=General%20Questions).  That is how the category is passed from the hyperlink to the category.aspx page.

  • How to clear off a SQL server quickly...

    So I was asked in an online community how to quickly clean off a SQL Server to rebuild a MOSS Farm.  Although it won't clean up and "add-ins" to the system DB's or any security identities, this does a quick and dirty job...

    IF object_id('tempdb..#AllDatabases') IS NOT NULL DROP TABLE #AllDatabases

    CREATE TABLE #AllDatabases
    (
                id          INT IDENTITY,
                name     NVARCHAR(128)
    )

    DECLARE @dbname   nvarchar(128)
    DECLARE @counter  int
    DECLARE @maxcount int

    INSERT INTO #AllDatabases SELECT name FROM master..sysdatabases WHERE name NOT IN ('tempdb', 'master', 'model', 'msdb')

    SET @counter = 1
    SELECT @maxcount = MAX(id) FROM #AllDatabases

    WHILE @counter <= @maxcount
    BEGIN
        SELECT @dbname = name FROM #AllDatabases WHERE id = @counter
        Print 'Deleting DB ' + @dbname
        --Uncomment the next line to enable deleting all User DBs
        --DROP DATABASE @dbname
        SET @counter = @counter + 1
    END

    IF object_id('tempdb..#AllDatabases') IS NOT NULL DROP TABLE #AllDatabases

  • Service Account problems...

    I was asked a question the other day that I thought might be good to share...  The company had made some changes and suddenly SharePoint stopped working, and they got these errors in the Even log every minute (italics added for anonymity):

    --------------------------------------

    Event Type:      Error
    Event Source:      Office SharePoint Server
    Event Category:      Office Server Shared Services
    Event ID:      6482
    Date:            date
    Time:            time
    User:            N/A
    Computer:      computername
    Description:
    Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (ea45ac67-ede8-4be3-812c-193b10678515).
    Reason: Logon failure: the user has not been granted the requested logon type at this computer
    Techinal Support Details:
    System.ComponentModel.Win32Exception: Logon failure: the user has not been granted the requested logon type at this computer
       at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.SynchronizeDefaultContentSource(IDictionary applications)
       at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
       at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)
    --------------------------------------

    And:
    --------------------------------------

    Event Type:      Error
    Event Source:      Office SharePoint Server
    Event Category:      Office Server Shared Services
    Event ID:      6641
    Date:            date
    Time:            time
    User:            N/A
    Computer:      computer
    Description:
    The SSP Timer Job Distribution List Import Job was not run.
    Reason: Logon failure: the user has not been granted the requested logon type at this computer
    Technical Support Details:
    System.ComponentModel.Win32Exception: Logon failure: the user has not been granted the requested logon type at this computer
       at Microsoft.Office.Server.Utilities.WindowsSecurity.GetUserTokenFromCredentials(String userDomainName, String password, LogonType logonType)
       at Microsoft.Office.Server.Utilities.WindowsSecurity.GetUserTokenFromCredentials(String userDomainName, String password)
       at Microsoft.Office.Server.Administration.JobHandler.Execute(Object state, Boolean timedOut)
    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    --------------------------------------

    Turns out they had changed the service account (and done it correctly), but they forgot to grant the Logon as Service security right in the Local Security Admin tool for that account.  A good thing to remember :)  This is done automatically when run the SharePoint Product Install and Configuration Wizard (or run psconfig -cmd configdb -create)...


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts