Ultimate Picker, Spliting Output Options
LaurenceG
Posted: Sunday, October 19, 2008 2:21:40 PM

Rank: Enthusiast

Joined: 10/17/2008
Posts: 27
Location: London and Cardiff
Hi,

I'm Laurence, I'm a Umbraco newb. I come from a PHP background, and I'm pretty new to asp.net and XSLT. That said, I love it... Umbraco is one the best CMS's I've ever used.

I'm building my first project at the moment...

I've used the "Ultimate Picker" package, to allow a user to select some images from the media library on a piece of content.

This seems to work well, however I'm having trouble making a useful output...

I've written this XSLT, to break down the output...

Code:

<xsl:variable name="Upload" select="$currentPage/data [@alias = 'Upload']" />

<xsl:variable name="UploadSplit" select="umbraco.library:Split($Upload, ',')" />

   <xsl:for-each select="$UploadSplit/value">
      <xsl:variable name="UploadSplitItem" select="$UploadSplit/value" />
       <xsl:value-of select="$UploadSplitItem"/>
   </xsl:for-each>


The problem is...

My Input- 1153,1154,1156,1157
My code then removes the comma's - 1153115411561157
My Output - 1153115311531153

So I get output for each item that exists in my input, but I can't work out a way of outputing the input data.

Ideally I'd like to end up with these ID's being driven into IMG tags.

Hopefully that makes sense! My english is pretty poor, so sorry!

Lau
Dirk
Posted: Monday, October 20, 2008 8:30:27 AM

Rank: Umbracoholic

Joined: 9/27/2007
Posts: 1,123
Location: Belgium
Hi Lau,

Change

Code:
<xsl:for-each select="$UploadSplit/value">
  <xsl:variable name="UploadSplitItem" select="$UploadSplit/value" />
  <xsl:value-of select="$UploadSplitItem"/>
</xsl:for-each>


into

Code:
<xsl:for-each select="$UploadSplit/value">
  *<xsl:value-of select="."/>*&nbsp;
</xsl:for-each>


Outputs *1153* *1154* *1156* *1157*

Hope that helps.

Regards,
/Dirk



level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
LaurenceG
Posted: Monday, October 20, 2008 5:08:25 PM

Rank: Enthusiast

Joined: 10/17/2008
Posts: 27
Location: London and Cardiff
Thanks! That does help, and that also makes alot of sense...

I'm still having some trouble passing this, so I can display an image...

From looking at various bits of code, I figured I need to produce something along these lines...

Code:

<img>
      <xsl:attribute name="src">
        <xsl:value-of select="umbraco.library:GetMedia(ID-HERE, 'false')/data [@alias = 'umbracoFile']"/>
      </xsl:attribute>
</img>


I'm clearly a newb! ;) Thanks again! Lau
Dirk
Posted: Monday, October 20, 2008 6:17:58 PM

Rank: Umbracoholic

Joined: 9/27/2007
Posts: 1,123
Location: Belgium
Hi Lau,

Have tried this?

Code:
<img>
  <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia(., 'false')/data [@alias = 'umbracoFile']"/>
  </xsl:attribute>
</img>


Greetz,
/Dirk



level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
LaurenceG
Posted: Monday, October 20, 2008 6:21:56 PM

Rank: Enthusiast

Joined: 10/17/2008
Posts: 27
Location: London and Cardiff
I have, that seemed like the most logical apporach...

But it throws this error...

Code:

System.Xml.XPath.XPathException: Function 'umbraco.library:GetMedia()' has failed. ---> System.OverflowException: Value was either too large or too small for an Int32.
Dirk
Posted: Monday, October 20, 2008 6:25:13 PM

Rank: Umbracoholic

Joined: 9/27/2007
Posts: 1,123
Location: Belgium
Add an if statement

/Dirk


level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
LaurenceG
Posted: Monday, October 20, 2008 6:42:42 PM

Rank: Enthusiast

Joined: 10/17/2008
Posts: 27
Location: London and Cardiff
Fantastic that works! Forgive me for being naive, but why does adding an 'if' tag allow this to work?

Thanks for your time and help! Laurence
Dirk
Posted: Monday, October 20, 2008 6:53:04 PM

Rank: Umbracoholic

Joined: 9/27/2007
Posts: 1,123
Location: Belgium
Because when saving the xslt, it is checked against the top most node, which doesn't necessarily have the properties you're using in the xslt. And if that property doesn't exist, the param to GetMedia is null and therefore throwing an error.

Regards,
/Dirk




level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
LaurenceG
Posted: Monday, October 20, 2008 8:31:00 PM

Rank: Enthusiast

Joined: 10/17/2008
Posts: 27
Location: London and Cardiff
Ah gotcha! Thanks for the help :) it was really invaluable, hopefully I can contribute something back soon! :) L
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.