This project is read-only.

How to link post item attachment as "Download File" from a blog post?

Topics: Enhanced Blog Edition
Oct 16, 2008 at 3:32 PM
In the Posts list, we have a column for attachments. Unfortunately, we can not upload directly while creating a post unless the creation of post is configured from an email. In the default view of Posts list, we may not see this column as it was not included in the view. I added attachments column to default view.

I have attachment files in almost all the posts. In CKS:EBE feature and in the by default blog site, these attachments are not shown in the PostsLists page or Post page.

Is there a way to show the attachment in both PostsList and Post pages as Download link pointing to corresponding file ?

I did some ground-level work on this:
a. When I opened the sharepoint site in SharePoint designer, I see Attachments folder under Posts list.
b. Under Attachments folder, a folder is created and named as a number. I think this number is the post item id + 1. Ex: If the post id is 11, the folder name is 12. Under this 12 folder, I am able to see the attachment which I uploaded.
c. In Post.xsl file, when I entered following code, I am able to see the download link:

            <div class="entry">
                <xsl:value-of select="Body" disable-output-escaping="yes" />
                <a href="{$RelativeUrl}/Lists/Posts/Attachments/12/>Download File</a>

    In the above <a> tag, 12 represents the folder name under which file is residing.

I tried to put {ID} value in a variable and tried to increment by 1 to get the folder name in the above <a> tag.
 <xsl:variable name="foldername" select="number({ID})+1" />
This is not working and this statement hiding all the posts or post items while displaying.

I have following question:
I want to show the Download File link in Posts List page and individual post page. For this, can anyone help me out, how to retrieve the attachment file name and file path for each post item basing on post ID or any other way?

Note: I did changes in Posts.xsl and Post.xsl files. I didn't touch in any other files.

Appreciate all inputs.
Oct 16, 2008 at 8:37 PM

Firstly you have an error in your XSL. By using DebugView you will see this error in the are missing and end"

You can try this...

Add the following XSL into your template (match="/")

<xsl:copy-of select-'.'/>

This will show you the XML when you display the page. From there you may see your attachment link.

I normally put downloads into the media library and then link to it from the post.



Oct 16, 2008 at 10:01 PM
Vince, thank you very much for the reply.

While posting here, I forgot the quote. In the code, I placed the code.

The other two inputs are very interesting. I will try both of them.

- Sai Krishna
Oct 17, 2008 at 8:17 PM
I wrote code to upload documents into Media library. I also created a column in Media library to maintain the post id.  With the customizations I did, I am able to upload a file into Media library while creating a post.

Now, I am looking for showing the Download File link in Posts and individual post page. I want to place the Download File link along with other links like Comments, Links.

After checking all the xsl file, I understood that the relation between individual Post item and Media library item can not be retrieved directly by adding code in xsl file. I must modify the code placed under WebControls folder in CKS:EBE project in the CKS:EBE Extensions source code.

Vince: Can you please guide me in updating the appropriate files to show the Download File link on PostsList and individual post page?
Oct 17, 2008 at 8:41 PM
Essentially add another control to list downloads for the current post...

In Post.aspx
<ebe:list runat=server listname=media xsl-xslaname=downloads.xsl />


<xsl:param name="ListID"/>
<xsl:param name="QSID"/>
<xsl:apply-templates select="//rows/row[@PostID = $ListID]" />
<xsl:apply-templates select="//rows/row[@PostID = $QSID]" />

<xsl:template match="row">
Generate your download links here

Its a bit abbreviated, but hopefully you get the point. Not sure which param will work (they both should in the 2.5 beta).

HTH, Vince
Oct 23, 2008 at 7:46 PM

Added another control to list downloads for the current post.

And also tries to implement downloads.xsl file. But, was not successful in showing the download links.

Right now, as I mentioned earlier posts, I have uploaded files in Media library. I am looking for a way to show Download File link.

Is there any reference posts or information which can help out in completing this implementation?