Adding Attachments to SharePoint blogs

While SharePoint 2007 does offer a blog-template, this is actually quite minimalistic. Even though you can usually add attachments to every list item in sharepoint, this is not possible for blog posts.

Well, actually, attachments are enabled for blog posts, and if you’re using an editor such as Windows Live Writer all images and files are being added as attachments to the current post. But this just isn’t possible if you’re stuck with the web-editor for writing new posts.

So I did some digging on what’s needed to get SharePoint to offer attachments for blog posts.

First of all you should be aware, that you’re going to modify some files dear and near to SharePoint – this might not always be the recommended way 🙂

OK, let’s get started. Since we already noticed that attachments are enabled on the list of posts, we somehow need to get this darn button in the toolbar to appear.

Since the blogging feature is built-in into SharePoint it’s view definition is found in the DefaultTemplates.ascx within the %CommonProgramFiles%\Microsoft Shared\Web Server Extensions\12\Template\ControlTemplates. Within this file are a whole lot of Rendering-Templates defined. Based on the existing BlogForm Template I created my own Template called BlogFormExt.

<SharePoint:RenderingTemplate ID="BlogFormExt" runat="server">
    <Template>
        <SPAN id='part1'>
            <SharePoint:InformationBar runat="server"/>
            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&nbsp;" runat="server">
                    <Template_RightButtons>
                        <SharePoint:SaveAsDraftButton Text="<%$Resources:wss,tb_saveasdraft%>" runat="server"/>
                        <SharePoint:PublishButton Text="<%$Resources:wss,tb_publish%>" runat="server"/>
                        <SharePoint:GoBackButton runat="server"/>
                    </Template_RightButtons>
            </wssuc:ToolBar>
            <SharePoint:FormToolBar runat="server"/>
            <p><a href="javascript:UploadAttachment();">Attach Me!</a></p>
            <TABLE class="ms-formtable" style="margin-top: 8px;" border=0 cellpadding=0 cellspacing=0 width=100%>
            <SharePoint:ChangeContentType runat="server"/>
            <SharePoint:FolderFormFields runat="server"/>
            <SharePoint:ListFieldIterator runat="server"/>
            <SharePoint:ApprovalStatus runat="server"/>
            <SharePoint:FormComponent TemplateName="AttachmentRows" runat="server"/>
            </TABLE>
            <table cellpadding=0 cellspacing=0 width=100% style="margin-top: 10px;"><tr><td class="ms-formline"><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></td></tr></table>
            <TABLE cellpadding=0 cellspacing=0 width=100% style="padding-top: 7px"><tr><td width=100%>
            <SharePoint:ItemHiddenVersion runat="server"/>
            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&nbsp;" runat="server">
                    <Template_Buttons>
                        <SharePoint:InitContentType runat="server"/>
                        <SharePoint:CreatedModifiedInfo runat="server"/>
                    </Template_Buttons>
                    <Template_RightButtons>
                        <SharePoint:SaveAsDraftButton Text="<%$Resources:wss,tb_saveasdraft%>" runat="server"/>
                        <SharePoint:PublishButton Text="<%$Resources:wss,tb_publish%>" runat="server"/>
                        <SharePoint:GoBackButton runat="server"/>
                    </Template_RightButtons>
            </wssuc:ToolBar>
            </td></tr></TABLE>
        </SPAN>
        <SharePoint:AttachmentUpload runat="server"/>
    </Template>
</SharePoint:RenderingTemplate>

Important are the two highligthed lines. The first line adds a link to display a dialog to upload an attachment, the orher line adds the actual code for the dialog and stuff.

OK, so now we habe our new layout in place, that allows us to add attachments to new posts. Next we need to alter our blog to make use of this new template definition.

So using SharePoint-Designer open up the blog and navigate got the posts list. Open up the NewPost.aspx and find the webpart-element in the code view. There should be a line like

<TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">BlogForm</TemplateName>

which you wand to edit to

<TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">BlogFormExt</TemplateName>

This will use our new template-definition instead of the build-in template view.

This is basically all you need to do – well you also might want to edit the EditPost.aspx to use a template which enables the upload of new attachments; but I leave that to you.

Oh – one final note: this enables uploading attachments to a blog-post, but the attachments are not automatically displayed for e.g. as a list of items in the end of the post. You will have to add the links to the attachments in your post manually!.

Pimpin' the prompt

OK, here comes another part of pimp my whatever! Today’s feature is your always underestimated console prompt.

OK, after doing some pimping on your console, you might want to do more, to distinguish from the rest of us. Why not change the look of your prompt. How about:

set prompt=[%computername%] $d$s$t$_$p$_$_$+$g

which will give you:

[NPC008] 10.03.2008 17:54:40,76
C:\WINDOWS
>

Well, that’s neat 🙂 Or try something different:

set prompt=$m$_$p$g

which will yield in:

\\server\share
V:\>

Pimp my Windows!

Themes

Bereits seit Windows 2000 gibt es die Möglichkeit das Look&Feel von Windows mit Themes anzupassen.

Das von Microsoft entwickelte msstyle-Format erlaubt es, das Erscheinungsbild von Windows komplett anzupassen. Leider müssen dafür die msstyle-Vorlagen digital signiert sein, und das ist das Problem an der ganzen Sachen.

Eine Lösung dafür ist es, die uxtheme.dll von Microsoft auszutauschen, so daß auch nicht signierte Styles verwendet werden können. Grundsätzlich gibt es zwei Möglichkeiten um die uxtheme.dll zu patchen: manuell oder mit einem Multi-Patcher. Der Vorteil des Multi-Patchers ist, daß er das Betriebssystem automatisch erkennt und die DLL entsprechend austauscht. Bei dem manuellen Weg muss zunächst de Windows Dateischutz (Windows File Protection) umgangen werden, um die uxtheme.dll auszutauschen.

Der Weg über den Multi-Patcher ist recht einfach. Zunächst den aktuellen Patcher downloaden und dann ausführen. Dieser erkennt Windows XP RTM/SP1/SP2 und Windows 2003 automatisch und tauscht die entsprechende DLL aus. Wenn das Programm ausgeführt und der Button “Patch” getätigt wurde, muss so lange gewartet werden, bis der Windows-Dateischutz anspringt und meldet, dass Dateien durch unbekannte Dateien ersetzt wurden. Das Ersetzen der geänderten Datei durch den Windows-Dateischutz mit den Originaldateien muss über den Button “Abbrechen” verhindert werden, da sonst der Patchvorgang nicht erfolgreich abgeschlossen werden kann. Nach einem Neustart können nicht signierte Visual Styles verwendet werden.

Um das ganze manuell durchzuführen sind ein paar mehr Schritte notwendig. Zunächst muss die für das Betriebssystem passendende uxtheme.dll heruntergeladen werden (uxtheme für Windows 2003 Server, uxtheme für Windows XP SP2).

  1. Um den Windows Dateischutz zu umgehen muss zunächst im VerzeichnisC:\WINDOWS\System32\dllcache die Datei UXTheme.dll durch die heruntergeladene ausgetauscht werden.
  2. Das System muss als nächstes im abgesicherten Zustand gestartet werden (F8 beim Starten drücken)
  3. anschließend kann die uxtheme.dll im ‘system32’-Verzeichnis ausgetauscht werden. Dazu am besten folgendes in einer DOS-Box ausführen:
       ren %SystemRoot%\system32\uxtheme.dll uxtheme.bak
       copy %SystemRoot%\system32\dllcache\uxtheme.dll %SystemRoot%\system32\

Nachdem die uxtheme.dll gepatched wurde können nun beliebige visuelle Styles geladen werden. Dabei gibt es eine Vielzahl von Styles, die Windows XP bereits einen Hauch von Vista geben. Dazu zählt zum Beispiel ein Hauch von dem neuen Glas-Effekt.

Mehr Pimpin’

Wohin geht der Weg beim Pimpen von Windows?

Aber das Pimpin’ des Desktops geht noch weiter, hier sind ein paar Links, die Ausblicke auf das noch Mögliche geben.

Ganz besonders begeistert bin ich von BumpTop. Auf YouTube gibt es auch ein Video mit einer Demo des Desktops. Bei BumpTop geht es um eine ganz neue Art von Desktop-Organisation.

Für wen BumpTop noch zu abgehoben ist (zumal es ja auch bisher nur einen Prototypen gibt), der kann sich vielleicht mit einem Zwischending zwischen Vista und BumpTop anfreunden. Bei SphereSite geht es um die 3D-Darstellung von Windows.

Sehr ultimativ ist auch das Bery Project für Linux. Dabei handelt es sich ähnlich wie bei Vista auch um jede Menge visuelle Designs wie Glas und 3D Effekte.