|
|
Rank: Enthusiast
Joined: 7/21/2007 Posts: 26 Location: Ringe, Denmark
|
Hi I have this: Code: Template: <umbraco:Macro imgAlias="imgPic" Alias="Test" runat="server"></umbraco:Macro>
*** The Property alias of the Media Picker is (of cause) imgPic ***
XSLT: <?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="currentPage"/> <xsl:variable name="imgAlias" select="/macro/imgAlias"/> <xsl:template match="/">
<xsl:if test="$imgAlias != ''"> <a> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias=$imgAlias], 'false')/data [@alias='umbracoFile']" /> </xsl:attribute> <img> <xsl:attribute name="src"> <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text> <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias=$imgAlias], 'false')/data [@alias='umbracoFile']" /> <xsl:text>&width=100</xsl:text> <xsl:text>&height=100</xsl:text> <xsl:text>&constrain=true</xsl:text> </xsl:attribute> </img> </a> </xsl:if> </xsl:template>
</xsl:stylesheet>
Running on umbraco v 4.0.0 (Assembly version: 1.0.3219.29118) Beta and is working fine. I the copied the xslt to a new site's xslt file, created the tab/property needed and nothing happens. I have tried to write some ordenary text i the if statement at it is not written on the page, but something written in the xslt outside the if statement is written on the page. I also tried to change "<xsl:if test="$imgAlias != ''">" with "<xsl:if test="$imgAlias = ''"> As if it was not different from '' it must equals '' but it does not get into the if anyway. Does anyone have any clue on what's going on? The new site is running umbraco v 4.0.1 (Assembly version: 1.0.3373.718) /Lars Mortensen
|
|
Rank: Fanatic
Joined: 10/14/2007 Posts: 214 Location: Allerød, Denmark
|
Hi Lars, it sounds as if something is wrong with your imgAlias parameter. Did you spell it correctly and also add a value in your macro-call? You could try displaying the $imgAlias content outside the if. >Tommy blackpoint.dk - Umbraco workbench - for people suffering from xslt amnesia.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 634 Location: Bad Homburg, Germany
|
try Code:<xsl:if test="not(string($imgAlias))"> This works for me Thomas
• 2007/2008 MVP • www.thoehler.com • blog.thoehler.com • Bad Homburg, Germany
|
|
Rank: Enthusiast
Joined: 7/21/2007 Posts: 26 Location: Ringe, Denmark
|
Hi Tommy, I have copy/pasted so I hope not it is spell error. I have pasted the macro call at the top of the code section, and the macro itself underneath so you can see if I call it write. I have tried to write the variable outside the if with this code Code:<div> <xsl:attribute name="text"> <xsl:text>Start</xsl:text> <xsl:value-of select="$imgAlias" /> <xsl:text>Slut</xsl:text> </xsl:attribute> </div> I get this in the page sourcecode: "div text="StartSlut" />" so it does not output anything. (If I have done it right, its probably not the best way.) hoehler, if I try to use your code I get this error: Code:(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current) at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging) I have just upgraded to version "umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657)" Any other thoughts? /Lars
|
|
Rank: Fanatic
Joined: 10/14/2007 Posts: 214 Location: Allerød, Denmark
|
Lars, are you sure you created the imgAlias parameter correctly on the macro parameters tab - and are you sure you are passing a value when using the parameter? >Tommy blackpoint.dk - Umbraco workbench - for people suffering from xslt amnesia.
|
|
Rank: Enthusiast
Joined: 7/21/2007 Posts: 26 Location: Ringe, Denmark
|
Ahhhhhh sorry, no I had forgot there was a parameter tab on the Marco, and did not get it the first time you tried. Now the response thing I made responses what it's supposed to.
It still, however does not work, but will look into that and response back.
Thank you for your help so far.
|
|
 Rank: Umbracoholic
Joined: 7/19/2006 Posts: 1,025 Location: Benfleet, Essex, UK
|
OK norphf I recommend to help you debug before your if is to either do Code:<xsl:value-of select="$imgAlias" /> or Code:<xsl:copy-of select="$imgAlias" /> Warren :) Warren Buckley an Umbraco MVP 08-09 & level 1 certified developerAre you NEW to Umbraco? Download CWS to help you learn Umbraco quickly NOW Available from the Official Umbraco Package Repository
|
|
Rank: Enthusiast
Joined: 7/21/2007 Posts: 26 Location: Ringe, Denmark
|
Sorry for the long reply, its working now thank you all.
|
|
The forum has moved
This forum is no longer in use, so you can't reply to this message - please go to Our Umbraco
|
|
Guest |