Hi guys,
Im a little rusty and need some help please...
I have an image gallery that uses the umbGallery.
Basically, I have a check box (websiteFeatured) that is on the gallery document type.
If the user selects this, I want that gallery featured in the foot of the website on each page.
The structure in the content is:
Homepage
Gallery
A Gallery Name (project 1 for example)
Gallery Image
Gallery Image
Gallery Image
Another Gallery Name (project 2 for example)
Gallery Image
Gallery Image
Gallery Image
So if the user checks the box (websiteFeatured) on project 1, the images of that project will be displayed throughout the site.
Also, ideally the images could be displayed in random order but only show 3 at a time.
Hey Chriztian, thanks for the help.
I've just tried that and although I dont get an error with this code, nothing is displayed on the site. I have checked a project with images in as 'websiteFeatured'
<xsl:param name="currentPage" />
<xsl:variable name="maxItems" select="3" />
<xsl:template match="/">
<xsl:variable name="galleryNode" select="$currentPage/ancestor-or-self::*[@level = 2]" />
<!-- Process the Gallery selected for featuring -->
<xsl:apply-templates select="$galleryNode/umbGalleryAlbum[websiteFeatured = 1]" />
</xsl:template>
<xsl:template match="umbGalleryAlbum">
<xsl:for-each select="*[@isDoc]">
<!-- This is not *real* randomization... -->
<xsl:sort select="Exslt.ExsltMath:random() * @id" data-type="number" order="ascending" />
<xsl:if test="position() <= $maxItems">
<!-- Render the image as you would normally -->
<xsl:variable name="umbracoMediaFile" select="umbraco.library:GetMedia(current()/umbracoMediaFile, 'false')" />
<img src="{$umbracoMediaFile/umbracoFile}" width="257" height="176" alt="Featured Image"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
Could it be something to do with the way I am trying to render the images here:
Hi Chriztian, I've tried everything today. Still no output. it doesn't seem to be applying the template. I've changed levels, took out[@isDoc], removed the websiteFeatured=1 and still nothing.
Ive checked the document type aliases and the are all correct. I've changed them all to: umbGallery, umbGalleryAlbum, umbGalleryPhoto
<xsl:variable name="maxItems" select="3" />
<xsl:template match="/">
<xsl:variable name="galleryNode" select="$currentPage/ancestor-or-self::*[@level = 2]" />
<!-- Process the Gallery selected for featuring -->
<p>Before</p>
<xsl:apply-templates select="$galleryNode/umbGallery/umbGalleryAlbum[websiteFeatured = 1]" />
<p>After</p>
</xsl:template>
<xsl:template match="umbGalleryAlbum">
<xsl:for-each select="*[@isDoc]">
<!-- This is not *real* randomization... -->
<xsl:sort select="Exslt.ExsltMath:random() * @id" data-type="number" order="ascending" />
<xsl:if test="position() <= $maxItems">
<!-- Render the image as you would normally -->
<p>Loop Test</p>
<xsl:variable name="umbracoMediaFile" select="umbraco.library:GetMedia(current()/umbracoMediaFile, 'false')" />
<img src="{$umbracoMediaFile/umbracoFile}" width="257" height="176" alt="Featured Image"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
These are the levels in the content tree and websiteFeatured is checked or this project which uses the umbGalleryAlbum doc type:
Hi Chriztian,
Ive tried to simplify it a little to see if I can get to the bottom of the issue.
I have removed the websiteFeatured checkbox from the Gallery Album.
I was thinking that it could just randomly loop through and display any 3 Gallery Photos but it still wont work. I've even renamed the document type aliases just in case there was an error...
The structure in the content tree is still the same as the image i posted above.
I might have the level wrong here but i've tried every level and still nothing:
Hey again Chriztian,
I've managed to get it working but one slight issue:
The randomization doesnt seem to work. Any ideas?
(I have about 5 or 6 images with the websiteFeatured checked. I was hoping for it to randomly select any 3 of those images)
Help featuring an image gallery on the website
Hi guys, Im a little rusty and need some help please...
I have an image gallery that uses the umbGallery.
Basically, I have a check box (websiteFeatured) that is on the gallery document type. If the user selects this, I want that gallery featured in the foot of the website on each page.
The structure in the content is:
So if the user checks the box (websiteFeatured) on project 1, the images of that project will be displayed throughout the site. Also, ideally the images could be displayed in random order but only show 3 at a time.
I was thinking something like this:
Now I know this code is incorrect but I hope it gives an idea of what i'm trying to acheive.
Any help would be greatly appreciated!
thanks!
Hi Roger,
You could maybe try something like this:
Hope that helps,
/Chriztian
Hey Chriztian, thanks for the help. I've just tried that and although I dont get an error with this code, nothing is displayed on the site. I have checked a project with images in as 'websiteFeatured'
Could it be something to do with the way I am trying to render the images here:
I am using the Upload datatype.
Or perhaps I have the level wrong but I was sure it was 2
Thanks again!
Roger
Hi Roger,
Let's see if we can figure out what's happening - can you try adding some output before and after the
apply-templates
instruction? Like this:And then add something similar inside the
for-each
, to see if it is even being hit?/Chriztian
Hi Chriztian, Ok i've tried that and the before and after outsputs ok around the apply templates but nothing outputs in the loop.
Thanks again
Roger
Alright - that means one or more of these are to blame:
$galleryNode
is selected wrongly (wrong level?)$galleryNode
(or none with the websiteFeatured checkbox checked)Try adding some more debug output in other locations to determine which is the case.
/Chriztian
Hi Chriztian, I've tried everything today. Still no output. it doesn't seem to be applying the template. I've changed levels, took out[@isDoc], removed the websiteFeatured=1 and still nothing.
Ive checked the document type aliases and the are all correct. I've changed them all to: umbGallery, umbGalleryAlbum, umbGalleryPhoto
These are the levels in the content tree and websiteFeatured is checked or this project which uses the umbGalleryAlbum doc type:
Thanks again for the help
Hi Chriztian, Ive tried to simplify it a little to see if I can get to the bottom of the issue. I have removed the websiteFeatured checkbox from the Gallery Album.
I was thinking that it could just randomly loop through and display any 3 Gallery Photos but it still wont work. I've even renamed the document type aliases just in case there was an error...
The structure in the content tree is still the same as the image i posted above.
I might have the level wrong here but i've tried every level and still nothing:
Thanks again
Roger
Hey again Chriztian, I've managed to get it working but one slight issue:
The randomization doesnt seem to work. Any ideas? (I have about 5 or 6 images with the websiteFeatured checked. I was hoping for it to randomly select any 3 of those images)
Anyway, its almost there!
Thanks
Roger
is working on a reply...