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

Topics: Enhanced Blog Edition
Oct 16, 2008 at 2: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/xyz.zip>Download File</a>
             </div>

    In the above <a> tag, 12 represents the folder name under which xyz.zip 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.
Developer
Oct 16, 2008 at 7:37 PM

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

You can try this...

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

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

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.

 

--Vince

Oct 16, 2008 at 9: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 7: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?
Developer
Oct 17, 2008 at 7: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...

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

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

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 6:46 PM
Vince,

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?