Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Damian Gostomski 3 posts 23 karma points
    Aug 25, 2010 @ 14:38
    Damian Gostomski
    0

    Image gallery and getMedia woes

    I seem to be having some major problems with getMedia within XSLT. I'm using Umbraco 4.5.1 so I know I need to use the format $currentPage/thumbnail (thumbnail being the alias of the media picker data type used on all pages).

    Just so you have an idea of what I'm trying to built, the end result should be like http://and-digital.com/clients/kantar/master/index.php?site=audience&template=gallery (It's amazing how much easier it was to build as a static page)

    I have the following XSLT code which can return the image path for the current page, and it works in certain cases...

    <xsl:output method="xml" omit-xml-declaration="no"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
      <xsl:if test="$currentPage/thumbnail != ''">
      <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/thumbnail, false)" />
        <xsl:value-of select="$media/umbracoFile"/>
      </xsl:if>
    </xsl:template>

    This will work on this page

    http://localhost:8080/television/people-meter-technology.aspx

    But not on

    http://localhost:8080/news-resources/multimedia-centre/gallery.aspx

    (Obviously clicking on those will do nothing, but I think the key point is that the second one is a level deeper)

    Investigating further, the XML for $currentNode when I call the XSLT macro in the second page seems to return a lot more than just the current page. It seems to return the adjascent and child nodes to it. The XML that is $currentNode is

    <Content id="1101" parentID="1100" level="3" writerID="0" creatorID="0" nodeType="1068" template="1107" sortOrder="1" createDate="2010-08-24T11:50:04" updateDate="2010-08-24T15:24:34" nodeName="Multimedia Centre" urlName="multimedia-centre" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101" isDoc=""><bodyText>
    <p><span class="xml-text">Sed egestas, ante et vulputate volutpat,
    eros pede semper est, vitae luctus metus libero eu augue. Morbi
    purus libero, faucibus adipiscing, commodo quis, gravida id, est.
    Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem
    at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque
    euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede
    arcu, dapibus eu, fermentum et, dapibus sed, urna. Sed egestas,
    ante et vulputate volutpat, eros pede semper est, vitae luctus
    metus libero eu augue. Morbi purus libero, faucibus adipiscing,
    commodo quis, gravida id, est. Sed lectus. Praesent elementum
    hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat,
    lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc
    sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et,
    dapibus sed, urna.</span></p>
    </bodyText><metaTitle /><metaDescription></metaDescription><metaKeywords /><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt>
    <Content id="1108" parentID="1101" level="4" writerID="0" creatorID="0" nodeType="1068" template="1110" sortOrder="1" createDate="2010-08-24T14:56:30" updateDate="2010-08-24T15:28:07" nodeName="Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat." urlName="morbi-in-sem-quis-dui-placerat-ornare-pellentesque-odio-nisi,-euismod-in,-pharetra-a,-ultricies-in,-diam-sed-arcu-cras-consequat" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101,1108" isDoc=""><bodyText>
    <p>Sed egestas, ante et vulputate volutpat, eros pede semper est,
    vitae luctus metus libero eu augue. Morbi purus libero, faucibus
    adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent
    elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum
    volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu
    pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu,
    fermentum et, dapibus sed, urna. Sed egestas, ante et vulputate
    volutpat, eros pede semper est, vitae luctus metus libero eu augue.
    Morbi purus libero, faucibus adipiscing, commodo quis, gravida id,
    est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper
    lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi
    neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus
    pede arcu, dapibus eu, fermentum et, dapibus sed, urna. lacus a
    ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien
    ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus
    sed, urna.<br />
    <br />
    Sed egestas, ante et vulputate volutpat, eros pede semper est,
    vitae luctus metus libero eu augue. Morbi purus libero, faucibus
    adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent
    elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum
    volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu
    pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu,
    fermentum et, dapibus sed, urna. Sed egestas, ante et vulputate
    volutpat, eros pede semper est, vitae luctus metus libero eu augue.
    Morbi purus libero, faucibus adipiscing, commodo quis, gravida id,
    est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper
    lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi
    neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus
    pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>
    </bodyText><metaTitle>A custom title</metaTitle><metaDescription>My meta description</metaDescription><metaKeywords>My meta keywords</metaKeywords><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt>
    </Content>
    <Content id="1109" parentID="1101" level="4" writerID="0" creatorID="0" nodeType="1068" template="1044" sortOrder="2" createDate="2010-08-24T15:16:56" updateDate="2010-08-24T15:16:42" nodeName="Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat. (1)" urlName="morbi-in-sem-quis-dui-placerat-ornare-pellentesque-odio-nisi,-euismod-in,-pharetra-a,-ultricies-in,-diam-sed-arcu-cras-consequat-(1)" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101,1109" isDoc=""><bodyText>
    <p>Sed egestas, ante et vulputate volutpat, eros pede semper est,
    vitae luctus metus libero eu augue. Morbi purus libero, faucibus
    adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent
    elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum
    volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu
    pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu,
    fermentum et, dapibus sed, urna. Sed egestas, ante et vulputate
    volutpat, eros pede semper est, vitae luctus metus libero eu augue.
    Morbi purus libero, faucibus adipiscing, commodo quis, gravida id,
    est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper
    lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi
    neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus
    pede arcu, dapibus eu, fermentum et, dapibus sed, urna. lacus a
    ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien
    ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus
    sed, urna.<br />
    <br />
    Sed egestas, ante et vulputate volutpat, eros pede semper est,
    vitae luctus metus libero eu augue. Morbi purus libero, faucibus
    adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent
    elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum
    volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu
    pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu,
    fermentum et, dapibus sed, urna. Sed egestas, ante et vulputate
    volutpat, eros pede semper est, vitae luctus metus libero eu augue.
    Morbi purus libero, faucibus adipiscing, commodo quis, gravida id,
    est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper
    lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi
    neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus
    pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>
    </bodyText><metaTitle>A custom title</metaTitle><metaDescription>My meta description</metaDescription><metaKeywords>My meta keywords</metaKeywords><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt>
    </Content>
    <Content id="1113" parentID="1101" level="4" writerID="0" creatorID="0" nodeType="1068" template="1097" sortOrder="5" createDate="2010-08-24T15:59:21" updateDate="2010-08-25T12:29:07" nodeName="Gallery Title goes here" urlName="gallery-title-goes-here" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101,1113" isDoc="">
    <Content id="1115" parentID="1113" level="5" writerID="0" creatorID="0" nodeType="1068" template="1044" sortOrder="2" createDate="2010-08-24T16:01:45" updateDate="2010-08-25T12:24:06" nodeName="Photo 1" urlName="photo-1" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101,1113,1115" isDoc=""><bodyText>
    <p>A short description about this photo goes here</p>
    </bodyText><metaTitle /><metaDescription></metaDescription><metaKeywords /><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt><thumbnail>1131</thumbnail></Content>
    <Content id="1116" parentID="1113" level="5" writerID="0" creatorID="0" nodeType="1068" template="1044" sortOrder="3" createDate="2010-08-24T16:30:45" updateDate="2010-08-25T12:24:19" nodeName="Photo 2" urlName="photo-2" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101,1113,1116" isDoc=""><bodyText>
    <p>Another photo and desc</p>
    </bodyText><metaTitle /><metaDescription></metaDescription><metaKeywords /><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt><thumbnail>1132</thumbnail></Content>
    <Content id="1118" parentID="1113" level="5" writerID="0" creatorID="0" nodeType="1068" template="1044" sortOrder="4" createDate="2010-08-24T16:37:33" updateDate="2010-08-25T12:24:29" nodeName="Photo 4" urlName="photo-4" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101,1113,1118" isDoc=""><bodyText>
    <p>sdfsdf</p>
    </bodyText><metaTitle /><metaDescription></metaDescription><metaKeywords /><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt><thumbnail>1133</thumbnail></Content>
    <Content id="1119" parentID="1113" level="5" writerID="0" creatorID="0" nodeType="1068" template="1044" sortOrder="5" createDate="2010-08-24T16:39:24" updateDate="2010-08-24T16:39:07" nodeName="Photo 3" urlName="photo-3" writerName="Administrator" creatorName="Administrator" path="-1,1048,1100,1101,1113,1119" isDoc=""><bodyText>
    <p>iii</p>
    </bodyText><metaTitle /><metaDescription></metaDescription><metaKeywords /><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt></Content>
    <bodyText>
    <p>Sed egestas, ante et vulputate volutpat, eros pede semper est,
    vitae luctus metus libero eu augue. Morbi purus libero, faucibus
    adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent
    elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum
    volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu
    pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu,
    fermentum et, dapibus sed, urna. Sed egestas, ante et vulputate
    volutpat, eros pede semper est, vitae luctus</p>

    <p>Sed egestas, ante et vulputate volutpat, eros pede semper est,
    vitae luctus metus libero eu augue. Morbi purus libero, faucibus
    adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent
    elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum
    volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu
    pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu,
    fermentum et, dapibus sed, urna. Sed egestas, ante et vulputate
    volutpat, eros pede semper est, vitae luctus</p>

    <p>Sed egestas, ante et vulputate volutpat, eros pede semper est,
    vitae luctus metus libero eu augue. Morbi purus libero, faucibus
    adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent
    elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum
    volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu
    pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu,
    fermentum et, dapibus sed, urna. Sed egestas, ante et vulputate
    volutpat, eros pede semper est, vitae luctus</p>
    </bodyText><metaTitle /><metaDescription></metaDescription><metaKeywords /><accessLevel></accessLevel><umbracoNaviHide>0</umbracoNaviHide><excerpt></excerpt><thumbnail>1134</thumbnail>
    </Content>
    </Content>

    The correct currentNode that I would expect to receive is Content node with ID 1113 which has 4 children nodes, and it's these 4 child nodes I want to then iterate over to create the gallery contents, but also to display the thumbnail for it (which it has, ID 1134)

    Where am I going wrong? Any help is much appreciated, as this has been driving me crazy!

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Aug 25, 2010 @ 14:49
    Warren Buckley
    0

    Hello Damian,
    OK on this page
    http://localhost:8080/television/people-meter-technology.aspx odes it have the property with the alias called thumbnail on it?

    But does this page that it is not working on have the thumbnail property on it?
    http://localhost:8080/news-resources/multimedia-centre/gallery.aspx

    As skimming through your XML snippets above its not outputting the thumbnail property?
    Did you create the pages that are not working after you added the thumbnail property, if so then you need to republish that node for the XML cache to be updated so that the property thumbnail will be added to the xml <thumbnail>1134</thumbnail>

    Warren

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 25, 2010 @ 14:51
    Morten Bock
    0

    Well, it does indeed look like there is something going in with regard to which page that is actually the current one.

    Looks like to me that it is the alternateTemplates that might be giving you a hard time.

    As far as I can see, the url that you actually want to visit is:

    http://localhost:8080/news-resources/multimedia-centre/gallery-title-goes-here.aspx

    Which is the url for the page. My guess is that you have a template called "gallery", and umbraco has a trick that means that:

    http://localhost:8080/news-resources/multimedia-centre/gallery.aspx

    will actuall be interpretede as

    http://localhost:8080/news-resources/multimedia-centre.aspx?altTemplate=gallery

    Does this make sense?

  • Damian Gostomski 3 posts 23 karma points
    Aug 25, 2010 @ 15:01
    Damian Gostomski
    0

    Hi Warren, thanks for the prompt reply

    Both pages have the thumbnail property and both of them have something from the Media picker selected.

    If my understanding is correct, the XML for $currentPage shouldn't contain the path, just the thumbnail IDs (which is has at the very end). Once I can get the correct ID it will just be a case of doing

    <xsl:variable name="media" select="umbraco.library:GetMedia(THE_ID, false)" />
    <xsl:value-of select="$media/umbracoFile"/>

    The pages were created before (thumbnail is part of a base document type which all document types inherit from) but I've tried republishing everything just in case but it didn't make a difference =(

    Any other ideas? And is it normal to get back that much XML for $currentPage instead of just the actual current page?

    Thanks

  • Damian Gostomski 3 posts 23 karma points
    Aug 25, 2010 @ 15:04
    Damian Gostomski
    0
    Morten, you've cracked it in one! Not sure why it was publishing to that URL though as oppose to the full one (actually, now that I think about it, the node name may have been just Gallery).
    So if I rename the gallery template this problem won't crop up again?
    Thanks =)
  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 25, 2010 @ 15:07
    Morten Bock
    0

    In general for the $currentPage parameter, it is actually more of a "pointer" than it is an entity. I gives you the current pages "position" in the xml content cache, and from there you can navigate to anywhere else in the site.

    So when doing a copy-of the $currenhtPage, you will get a copy of the entire xml struture from the current "position" in the tree.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 25, 2010 @ 15:10
    Morten Bock
    0

    Correct. If you rename the template it should not be a problem.

    But umbraco _should_ actually prefer an actual content page over an alternate template if the both match the. So you could try and rename the page to "gallery" again, and see if it works that way as well.

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Aug 25, 2010 @ 15:10
    Warren Buckley
    0

    OK glad that Morten has solved the problem for you.
    If you need anymore help just shout.

Please Sign in or register to post replies

Write your reply to:

Draft