Has anyone had any luck in getting the Category images to show? I am a bit of a newbie to XSLT and cant seem to find any way of chaging the Category[XSLT] to pick up @Image attribute, I can get the ID through but thats about it. Does anyone have any ideas?
Thanks for this, but I still cant seem to get this to work and just get the "Error Parsing XSLT". I am guesing that 'myCatalog' and 'myCategory' were to be changed as per my project. But dont seem to get anything. I used this code, with this structure - is this right?
Yes you are correct 'myCatalog' and 'myCategory' are to be substituted for your actual catalog and category names. Keep in mind this is a very simplistic example used to capture a targeted category and simply build an image tag. Your syntax looks correct assuming your running in the newer xslt schema of umbraco.
You might try first to reverse engineer a bit your xpath statement in order to determine where the mishap is occuring. Looking at your structure I would first try to simply emit the raw xml for your "category" of choice with something like this:
Place this snippet just below your <template match="/"> tag
Load the page and make sure this textbox returns xml representing your category. If so then look in the xml for the "image" element which should show a number if you have loaded an image for it. What you want is this image number so you can pass it to the GetMedia function along with the "/umbracoFile" at the very end to get the actual image filename. Hopefully this will get you started.
Thanks for this, I tried adding this textarea and couldnt get anything to return, apart from setting the fields to ":GetCategory(23,84)" which is the Products Page Id and the "Oils and Fats" category from the image above, even at the higher level it was bringing through a blank text area and all other child folder were blank also. The text area only gave me the text "falsefalsefalsetruefalse" which I wasn't expecting to come back.
Could I be doing something wrong with this?
Again I appreciate the help you are giving me with this.
Apologies Jason, I wrongly coded the textarea after having a 2nd look at what I typed above (doh!) Below is the corrected code. I sometimes type before I think ;)
As an aside if the page was working correctly to begin with, you should be safe in using the variables catalogName and categoryName which are assigned at the top of the xslt file but you can substitue ID's until things start coming around. Below I'm using the variables. This should return the XML structure and you should be able to confirm you have an image ID for the picture your attempting to load.
Ah, I thought that was wrong so did that yesterday too, again I dont get anything in the textarea, but in the images I do get the top level images(the 'products' level) and not pick up the category images which is what I need, its almost as if I'm missing another level down the tree. I feel it is almost there, just missing that little piece of information that my knowledge lacks.
Soren, is this the default store that comes with the uCommerce package? This is what I have been using and cant find any examples. Is there somewhere else I should be looking.
The store is available from the download page on our site (scroll down a bit). It's installed as a separate package and includes a bunch of macros for doing everything you need.
I noticed that if the image was defined in the back end of the uCommerce then it would throw an XSLT error and couldnt find any was of fixing this. But managed to get the images brought through eventually. If anyone is looking for the snippet of code, I used this
Category Images to Show
Hi,
Has anyone had any luck in getting the Category images to show? I am a bit of a newbie to XSLT and cant seem to find any way of chaging the Category[XSLT] to pick up @Image attribute, I can get the ID through but thats about it. Does anyone have any ideas?
Thanks
Jason
This should do it:
<img id="img">
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia(CommerceLibrary:GetCategory('myCatalog','myCategory')/category/@image,true())/umbracoFile"/>
</xsl:attribute>
</img>
Hi Phil,
Thanks for this, but I still cant seem to get this to work and just get the "Error Parsing XSLT". I am guesing that 'myCatalog' and 'myCategory' were to be changed as per my project. But dont seem to get anything. I used this code, with this structure - is this right?
<img id="img">
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia(CommerceLibrary:GetCategory('ProductsPage','Products')/category/@image,true())/umbracoFile"/> </xsl:attribute>
</img>
Thanks
Jason
Yes you are correct 'myCatalog' and 'myCategory' are to be substituted for your actual catalog and category names. Keep in mind this is a very simplistic example used to capture a targeted category and simply build an image tag. Your syntax looks correct assuming your running in the newer xslt schema of umbraco.
You might try first to reverse engineer a bit your xpath statement in order to determine where the mishap is occuring. Looking at your structure I would first try to simply emit the raw xml for your "category" of choice with something like this:
<textarea>
<xsl:value-of select="CommerceLibrary:GetCategory('ProductsPage','Products')" />
</textarea>
Place this snippet just below your <template match="/"> tag
Load the page and make sure this textbox returns xml representing your category. If so then look in the xml for the "image" element which should show a number if you have loaded an image for it. What you want is this image number so you can pass it to the GetMedia function along with the "/umbracoFile" at the very end to get the actual image filename. Hopefully this will get you started.
Hi Phil
Thanks for this, I tried adding this textarea and couldnt get anything to return, apart from setting the fields to ":GetCategory(23,84)" which is the Products Page Id and the "Oils and Fats" category from the image above, even at the higher level it was bringing through a blank text area and all other child folder were blank also. The text area only gave me the text "falsefalsefalsetruefalse" which I wasn't expecting to come back.
Could I be doing something wrong with this?
Again I appreciate the help you are giving me with this.
Thanks
Jason
Apologies Jason, I wrongly coded the textarea after having a 2nd look at what I typed above (doh!) Below is the corrected code. I sometimes type before I think ;)
As an aside if the page was working correctly to begin with, you should be safe in using the variables catalogName and categoryName which are assigned at the top of the xslt file but you can substitue ID's until things start coming around. Below I'm using the variables. This should return the XML structure and you should be able to confirm you have an image ID for the picture your attempting to load.
<textarea>
<xsl:copy-of select="CommerceLibrary:GetCategory('$catalogName,$categoryName)" />
</textarea>
Ah, I thought that was wrong so did that yesterday too, again I dont get anything in the textarea, but in the images I do get the top level images(the 'products' level) and not pick up the category images which is what I need, its almost as if I'm missing another level down the tree. I feel it is almost there, just missing that little piece of information that my knowledge lacks.
Thanks again.
@Jason: If you take a look at the default store you'll see some example of how to display images using the Umbraco XSLT API.
@Phil: Thanks for helping out. Much appreciated!
Soren, is this the default store that comes with the uCommerce package? This is what I have been using and cant find any examples. Is there somewhere else I should be looking.
Thanks
The store is available from the download page on our site (scroll down a bit). It's installed as a separate package and includes a bunch of macros for doing everything you need.
I noticed that if the image was defined in the back end of the uCommerce then it would throw an XSLT error and couldnt find any was of fixing this. But managed to get the images brought through eventually. If anyone is looking for the snippet of code, I used this
but remember that all categories need to have an image assigned to them.
Thanks
Jason
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.