Copied to clipboard

Flag this post as spam?

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


  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 10:55
    sandro
    0

    Can't load article image, always loads default one

    Here is the code:
    http://pastebin.com/AmPsewxG

    I inherited this project from a colleuge, and I'm very bad with XSLT , I wonder is there any obvious mistake with this code. Here is the layout of pagination :
    The blue scribble is there to hide the logo, anyways the logo loads as the default but I can't load the real article image.

  • Dennis Aaen 4470 posts 18049 karma points admin hq c-trib
    Mar 06, 2015 @ 11:02
    Dennis Aaen
    0

    Hi sandro and welcome to our.

    I think that this code should do it for you

    <xsl:when test="./data [@alias = 'articlePhoto'] != ''">
        <xsl:variable name="articlePhoto" select="umbraco.library:GetMedia(./data [@alias = 'articlePhoto'], 0)" />
        <div class="col-md-3">
         <img src="{$articlePhoto/data [@alias = 'umbracoFile']}" />
            </div>
    </xsl:when>

    <xsl:otherwise>
        <div class="col-md-3">
        <img  src="/media/1026/fake-logo.jpg" alt="{@nodeName}" style = "display:inline;width:230px;height:100px;" />
        </div>
    </xsl:otherwise>

    Hope this helps,

    /Dennis

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Mar 06, 2015 @ 11:03
    Jan Skovgaard
    0

    Hi Sandro and welcome to our :)

    Judging from the XSLT syntax I guess your site is running Umbraco 4.0.x - Is that correct?

    Has there been selected an image on the articles where the default logo is just loaded instead?

    /Jan

  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 11:35
    sandro
    0

    Thanks for such a fast and nice welcome :)
    The site is running Umbraco 7.1.8, here you can see that i selected an image for this test article 
    Dennis's code dosen't work,  here is the template code
    http://pastebin.com/tjxnwKe6
     
     Here is the News item document type
     

  • Dennis Aaen 4470 posts 18049 karma points admin hq c-trib
    Mar 06, 2015 @ 11:48
    Dennis Aaen
    0

    Hi Sandro,

    Sicnce you are using Umbraco 7.1.8, then I assume that you are using the new XML schema, it was introduced in Umbraco 4.5. Then you need to write you XSLT code a bit different.

    <xsl:when test="./articlePhoto != ''">
        <xsl:variable name="articlePhoto"select="umbraco.library:GetMedia(./articlePhoto, 0)"/>
        <div class="col-md-3">
            <img src="{$articlePhoto/umbracoFile}"/>
        </div>
    </xsl:when>

    <xsl:otherwise>
        <div class="col-md-3">
            <img src="/media/1026/fake-logo.jpg"alt="{@nodeName}"style="display:inline;width:230px;height:100px;"/>
        </div>
    </xsl:otherwise>

    And make sure that the alias for the image field is articlePhoto, the name and alias are to different things. You can find the documentation for the getMedia in XSLT here: https://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    Hope this helps,

    /Dennis

  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 13:27
    sandro
    0

    Ah this is frustrating, can't get it to work. I think it's the older version of xslt because i get errors when i use the code from the new one ,  I also made sure that the alias is correct, and i even added another field just to be sure. When i open the article ( press read more ) i can see the image as a header but i need this small version next to the summarized text, thanks for your help guys :) 

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Mar 06, 2015 @ 13:38
    Jan Skovgaard
    0

    Hi Sandro

    I don't think that's possible. Since the release of v7.1.x it has not been possible to activate the legacy xml schema. So I would be very surprised if it was.

    What kind of errors are you getting? Keep in mind that it's not sure the examples provided in here are correct either. It would also be nice to see all of your code to fully grasp the context.

    Looking forward to hearing from you.

    /Jan

  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 13:42
    sandro
    0

    http://pastebin.com/FThDkppU
    Here is the whole xslt file 

    http://pastebin.com/tjxnwKe6
    Here is the template code

    The alias for the image is articlePhoto 

     

  • Dennis Aaen 4470 posts 18049 karma points admin hq c-trib
    Mar 06, 2015 @ 13:51
    Dennis Aaen
    0

    Hi sandro,

    Try this one, and make sure that the alias is of the image field is image. Try to see where to find the alias of the field http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/document-types/properties/

    <xsl:when test="./image != ''">
        <xsl:variable name="articlePhoto"select="umbraco.library:GetMedia(./image, 0)"/>
        <div class="col-md-3">
            <img src="{$articlePhoto/umbracoFile}"/>
        </div>
    </xsl:when>

    <xsl:otherwise>
        <div class="col-md-3">
            <img src="/media/1026/fake-logo.jpg"alt="{@nodeName}"style="display:inline;width:230px;height:100px;"/>
        </div>
    </xsl:otherwise>

    Hope this helps,

    /Dennis

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Mar 06, 2015 @ 14:07
    Jan Skovgaard
    0

    Hi Sandro

    What does the error messages you're getting say?

    /Jan

  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 14:14
    sandro
    0

     

     

     

    This is the error message
     

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Mar 06, 2015 @ 14:42
    Jan Skovgaard
    0

    Hi Sandro

    Could you please try going to the /app_data/logs file and see if you can find the error text there? I'm suspecting that there should be a line number somewhere, which might have been cropped from the top in the image you have posted above.

    The issue might be that XSLT support changed a bit with the release of v7.1 so some things might need to be done a bit differently...If I recall correctly some things are stored in a different way in the /App_Data/umbraco.config file.

    /Jan

  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 14:58
    sandro
    0

    http://pastebin.com/WcHSt1De
    Here is the last log, at the end there seems to be problem with page node 

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Mar 06, 2015 @ 15:02
    Jan Skovgaard
    0

    Hi Sandro

    Hmm, actually there is no trace of the error you're seeing in your XSLT file in there.

    Some of it is just INFO stuff, that you most times don't need to care about. Not quite sure what could be wrong with your code - The screendump you posted above...was it cropped or is that the full error you're getting when trying to save your XSLT?

    Have you tried to edit it outside of the Umbraco editor?

    /Jan

  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 15:19
    sandro
    0

    I just get this Error reading XSLT file: \xslt\PaginationExample.xslt, I used the last code you provided me 
     
    the only problem is the image not loading on the article summaries page, everything else is fine 

  • sandro 11 posts 31 karma points
    Mar 06, 2015 @ 19:24
    sandro
    0

    I decided to give up on XSLT and rewrite the paging in razor .. much easier :D

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Mar 06, 2015 @ 20:08
    Jan Skovgaard
    0

    Hi Sandro

    Ok, as long as you found a way to move forward. If it had been on a v4 or v6 installation I don't think it would have been so troublesome. With v7 it's probably better to go with Razor if you're not that familiar with XSLT.

    Happy coding!

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft