You most certainly don't need 100 different macros/xslt files.
What you can do is on your macro define a property which you can pass in (say the id of the media item) then in your XSLT you can reference it something like thid (suposing your macro property alias was imageId).
Are the pickers on the same page in your installation?
If you just want to pick let's say 100 different images to be shown the same way in the same page, I'd suggest you take a look at the multiple media picker in the uComponents package.
With this macro you can pick all the images that you want with just one property instead of 100. Just an idea...
Thank's man, that really helped. Here's the final XSLT in case anyone else needs to know. Btw, what's the difference between a variable and a parameter?
Do I need a seperate macro for each image?
If I have a bunch of content pickers, lets say 100 on a site. Do I need to write 100 different macros/xslt combos to display each image?
If not, can someone point me to an example where I shows a reusable macro?
Thanks!
Hi Nate,
You most certainly don't need 100 different macros/xslt files.
What you can do is on your macro define a property which you can pass in (say the id of the media item) then in your XSLT you can reference it something like thid (suposing your macro property alias was imageId).
From here, you could then just render it out in the main body of your template:
Matt
For the sake of clarity, you'd then probably have something like this in your template
[#...] is special syntax in umbraco which tells it to get the value from a property with that alias from the current document.
Matt
Hi Nate
Are the pickers on the same page in your installation?
If you just want to pick let's say 100 different images to be shown the same way in the same page, I'd suggest you take a look at the multiple media picker in the uComponents package.
With this macro you can pick all the images that you want with just one property instead of 100. Just an idea...
/Kim A
Thank's man, that really helped. Here's the final XSLT in case anyone else needs to know. Btw, what's the difference between a variable and a parameter?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="class" select="/macro/class" />
<xsl:param name="imgAlias" select="/macro/imgAlias" />
<xsl:param name="cropName" select="/macro/cropName" />
<xsl:param name="currentPage"/>
<xsl:template match="/">
<img>
<xsl:attribute name="src">
<xsl:if test="$imgAlias != '' ">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/*[local-name()=$imgAlias], false)/imageCropper//crop [@name = $cropName]/@url"/>
</xsl:if>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="$class"/>
</xsl:attribute>
</img>
</xsl:template>
</xsl:stylesheet>
double post...
http://msdn.microsoft.com/en-us/library/ms950787.aspx#xml0619_topic1
I found this link to be very helpful in explaining the difference.
is working on a reply...