First of all, i'm new to xslt and umbraco. I am trying to create a image gallery, which i can place in a article/page by inserting a macro. The macro has an mediaCurrent which i want to select the mediafolder to list images from. Is this possible ? I have tryed several things but cannot get it to work. Can someone help me in the right direction ?
So far i have this code, after many trial and errors:
You can definitely achieve what you want - you are on the right track ;-)
Without investigating your source in detail it seems you have an issue with your media id's. I have a similar snippet you can use for inspiration here.
Image gallery macro
Hi.
First of all, i'm new to xslt and umbraco.
I am trying to create a image gallery, which i can place in a article/page by inserting a macro. The macro has an mediaCurrent which i want to select the mediafolder to list images from. Is this possible ? I have tryed several things but cannot get it to work. Can someone help me in the right direction ?
So far i have this code, after many trial and errors:
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="mediafoldersource" select="/macro/mediafoldersource"/>
<xsl:template match="/">
<xsl:variable name="mediaId" select="umbraco.library:GetXmlNodeById($mediafoldersource)/self::node" />
<div class="ImageGallery">
<ul>
<xsl:if test="count($mediaId/data) > 0 and string($mediaId/data[@alias='umbracoFile']) != ''">
<xsl:for-each select="umbraco.library:GetMedia($mediaId)/self::node">
<xsl:choose>
<xsl:when test="@nodeTypeAlias = 'Image'">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile']"/>
</xsl:attribute>
<xsl:attribute name="rel">
<xsl:value-of select="string('colorbox')"/>
</xsl:attribute>
<img>
<xsl:attribute name="src">
<xsl:value-of select="Exslt.ExsltStrings:replace(umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile'], '.', '_thumb.')"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="@nodeName"/>
</xsl:attribute>
</img>
</a>
</li>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</ul>
</div>
</xsl:template>
Hi Mattis, welcome to the forum.
You can definitely achieve what you want - you are on the right track ;-)
Without investigating your source in detail it seems you have an issue with your media id's. I have a similar snippet you can use for inspiration here.
I hope it helps.
>Tommy
Hi Tommy :)
Thank you very much for your reply, this pointed me in the right direction and I ended up with this.
I'm glad you got it working.
>Tommy
Hi,
We have just releases Simpleviewer for Umbraco, available at http://our.umbraco.org//projects/website-utilities/simpleviewer-package-for-umbraco .
With this package you can use the www.simpleviewer.net gallery and pick the images from your media folder without writing a single line of code.
regards,
Pau
is working on a reply...