Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Jason Mackay 98 posts 149 karma points
    Mar 26, 2012 @ 17:12
    Jason Mackay
    0

    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

  • Phil 31 posts 53 karma points
    Mar 27, 2012 @ 06:58
    Phil
    0

    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>

  • Jason Mackay 98 posts 149 karma points
    Mar 27, 2012 @ 11:59
    Jason Mackay
    0

    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

  • Phil 31 posts 53 karma points
    Mar 27, 2012 @ 18:00
    Phil
    0

    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.

  • Jason Mackay 98 posts 149 karma points
    Mar 28, 2012 @ 15:03
    Jason Mackay
    0

    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

  • Phil 31 posts 53 karma points
    Mar 29, 2012 @ 03:24
    Phil
    0

    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>

     

  • Jason Mackay 98 posts 149 karma points
    Mar 29, 2012 @ 11:04
    Jason Mackay
    0

    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.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Mar 29, 2012 @ 15:06
    Søren Spelling Lund
    0

    @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!

  • Jason Mackay 98 posts 149 karma points
    Apr 04, 2012 @ 13:25
    Jason Mackay
    0

    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

  • Søren Spelling Lund 1797 posts 2786 karma points
    Apr 24, 2012 @ 08:37
    Søren Spelling Lund
    0

    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.

  • Jason Mackay 98 posts 149 karma points
    Apr 24, 2012 @ 15:33
    Jason Mackay
    0

    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

    <img>
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia(CommerceLibrary:GetCategory($catalogName, @id)/category/@image,true())/umbracoFile"/>
    </xsl:attribute>
    </img>

    but remember that all categories need to have an image assigned to them.

     

    Thanks

    Jason

Please Sign in or register to post replies

Write your reply to:

Draft