Umbraco, adding attachments to articles in back-end and then showing them in front-end CMS
Hello,
On my Umbraco website, I have the section which shows latest News. Each news is one article.
Unfortunately, I can't add any attachments to any News article in back-end so users could see that attachment(s) on front-end of website and download them if they want to. This is how I it should look like
Is this possible to do? While I was using Joomla CMS it was very easy by installing additional module/component which took me only 15 minutes to set.
Any help is appreciated and many thanks in advance for prompt replies!
Adi
From the picture you posted i assume you want to display a list of pdf from a media folder. What you can do is add a newDataType Media Picker "mediaFolderId" to your docType.
Under settings section go to your Media Type and whatever Media your are using to upload the pdfs. For example "File". Add a newDataType with alias "umbracoBytes" with type Label.
Since you are using xslt here is the code.
<xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:variable name="mediaFolderId" select="number($currentPage/mediaFolderId)" /> <xsl:template match="/"> <!-- Displays all images from a folder in the Media Library --> <xsl:if test="number($mediaFolderId)"> <ul> <xsl:for-each select="umbraco.library:GetMedia($mediaFolderId, true())/File"> <xsl:variable name="size" select="./umbracoBytes" /> <xsl:variable name="sizeAndSuffix"> <xsl:choose> <xsl:when test="$size >= 1048576"> <xsl:value-of select="format-number($size div 1048576,'#,###')"/> <xsl:text> MB</xsl:text> </xsl:when> <xsl:when test="$size >= 1024"> <xsl:value-of select="format-number($size div 1024,'#,###')"/> <xsl:text> KB</xsl:text> </xsl:when><xsl:when test="$size >= 1024">
<xsl:value-of select="format-number($size div 1024,'#,###')"/>
<xsl:text> KB</xsl:text>
</xsl:when>
<xsl:when test="$size > 0 and $size < 1024">
<xsl:value-of select="format-number($size div 0,'#,###')"/>
<xsl:text> Bytes</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0 Bytes</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="umbracoFile !=''">
<li>
<a href="{umbracoFile}" target='_blank'>
<xsl:value-of select="@nodeName"/>
[] <xsl:value-of select="$sizeAndSuffix"/>
</a>
</li> </xsl:if> </xsl:for-each> </ul> </xsl:if>
Umbraco, adding attachments to articles in back-end and then showing them in front-end CMS
Hello,
On my Umbraco website, I have the section which shows latest News. Each news is one article.
Unfortunately, I can't add any attachments to any News article in back-end so users could see that attachment(s) on front-end of website and download them if they want to. This is how I it should look like
Is this possible to do? While I was using Joomla CMS it was very easy by installing additional module/component which took me only 15 minutes to set.
Any help is appreciated and many thanks in advance for prompt replies! Adi
Hi Adi,
From the picture you posted i assume you want to display a list of pdf from a media folder. What you can do is add a newDataType Media Picker "mediaFolderId" to your docType.
Under settings section go to your Media Type and whatever Media your are using to upload the pdfs. For example "File". Add a newDataType with alias "umbracoBytes" with type Label.
Since you are using xslt here is the code.
Hope this helps
//fuji
Hello Fuji,
thank you very much for your reply, it was helpeful.
However, in the meantime I have find the solution here
http://our.umbraco.org/forum/using/ui-questions/47616-Adding-attachments-to-articles-in-back-end-and-then-showing-them-in-front-end-CMS
Thank you, Adi
Hey Adi,
Good to know you finally got it working but in razor instead of xslt at the end.
Anyways the end results is the most important and where you feel more comfortable/
Glad i could help
//Fuji
is working on a reply...