Copied to clipboard

Flag this post as spam?

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


  • Robert J. Bullock 386 posts 405 karma points
    Dec 15, 2011 @ 22:37
    Robert J. Bullock
    0

    'umbraco.MacroEngines.DynamicXml' does not contain a definition for 'Image

    I'm using DAMP 2.0 and for some reason, I get the above error with this simple script:

    @{
        if (Model.HasValue("photos"){
            dynamic mediaItems Model.photos.mediaItem;
            if (mediaItems.Count(!= 0)
            {
                <ul>
                @foreach (var item in mediaItems)
                {
                    var image item.Image;
                    <li>
                        Original image<href="@image.umbracoFile">@image.nodeName</a(@image.umbracoBytes bytes)<br />

                    </li>
                }
                </ul>
            }
        }
    }

    What's confusing me is I have the Cultiv 1.5 sample site installed (both above and it use 4.7.1) and it works fine! So I'm surmising it's a configuration issue, but what?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 16, 2011 @ 11:23
    Jeroen Breuer
    0

    Your code seems fine. Maybe you can try the DAMP 2.0 Samples package to see if that works.

    Jeroen

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Dec 16, 2011 @ 11:32
    Sebastiaan Janssen
    0

    Please also post a snippet from your umbraco.config where the damp items are stored so we can have a look at what might be wrong there. 

    Things I can think of right now:
    - Damp is not configured to store the full media xml in the umbraco.config
    - The property on your documentType isn't called "photos" but something else  (although, then you probably wouldn't get that far anyway)

  • Robert J. Bullock 386 posts 405 karma points
    Dec 16, 2011 @ 16:20
    Robert J. Bullock
    0

    This isn't from the umbraco.config, but if I use the ".ToHtml()" method on mediaItems, this is what I get:

    <root><mediaitem><node id="5507" version="feae5c3e-5438-4f78-8673-b76f6d410098" parentid="5506" level="3" writerid="0" nodetype="1032" template="0" sortorder="1" createdate="2011-12-16T10:16:12" updatedate="2011-12-16T10:16:13" nodename="IMG_1845" urlname="img_1845" writername="Administrator" nodetypealias="Image" path="-1,5505,5506,5507"><data alias="umbracoFile">/media/90927/img_1845.jpg</data><data alias="umbracoWidth">1728</data><data alias="umbracoHeight">1296</data><data alias="umbracoBytes">560754</data><data alias="umbracoExtension">jpg</data><data alias="caption"></data></node></mediaitem></root>

    Does that help?

  • Robert J. Bullock 386 posts 405 karma points
    Dec 16, 2011 @ 16:25
    Robert J. Bullock
    0

    And if I call .ToXml() on each item in the foreach loop I get this:

    <mediaItem><node id="5507" version="feae5c3e-5438-4f78-8673-b76f6d410098" parentID="5506" level="3" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2011-12-16T10:16:12" updateDate="2011-12-16T10:16:13" nodeName="IMG_1845" urlName="img_1845" writerName="Administrator" nodeTypeAlias="Image" path="-1,5505,5506,5507"><data alias="umbracoFile">/media/90927/img_1845.jpg</data><data alias="umbracoWidth">1728</data><data alias="umbracoHeight">1296</data><data alias="umbracoBytes">560754</data><data alias="umbracoExtension">jpg</data><data alias="caption" /></node></mediaItem>

    So, yeah, I'm really stumped!

  • Robert J. Bullock 386 posts 405 karma points
    Dec 16, 2011 @ 16:26
    Robert J. Bullock
    0

    I'm wondering, is it because I'm using the legacy XML schema?

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Dec 16, 2011 @ 16:26
    Sebastiaan Janssen
    0

    Not sure. What happens if you change item.Image to item.node ? 

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Dec 16, 2011 @ 16:28
    Sebastiaan Janssen
    0

    Aaah legacy schema, that explains the weirdly named "node" node..!

    Oh boy.. good luck with that. ;-) I'm not sure most of the Razor stuff works with the legacy schema to be honest. 

  • Robert J. Bullock 386 posts 405 karma points
    Dec 16, 2011 @ 16:29
    Robert J. Bullock
    0

    Oh man, that blows! I have a ton of XSLT's I never updated for this site... So in order to get Razor to work reliably I need to update the new XML schema? 

    Well, if I have to I have to I  guess...

  • Robert J. Bullock 386 posts 405 karma points
    Dec 16, 2011 @ 16:31
    Robert J. Bullock
    0

    Or... I could replace all the XSLT's with Razor scripts instead... Would that put me ahead of the game for 5.0?

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Dec 16, 2011 @ 16:32
    Sebastiaan Janssen
    0

    I am really not certain about it, but I've never met anybody who used the legacy schema with Razor. You're a brave man indeed! ;-)

    Make sure to create a good backup and then read these instructions: http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/switching-between-old-and-new-schema

    Also, for a semi-automatic conversion of your existing XSLT, have a look here (where it says "Optional: upgrade your xslt files to the 4.5 schema"): http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/switching-between-old-and-new-schema


  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Dec 16, 2011 @ 16:35
    Sebastiaan Janssen
    0

    v5 will have a new Model, you will be able to leverage your newfound Razor knowledge very well in v5, but don't expect your script to work exactly the same. It's a good learning experience, for sure. Depends on how much you are willing to invest at the moment. :-)

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 16, 2011 @ 16:36
    Jeroen Breuer
    0

    Hmm I think Razor won't work very well with the legacy schema so it's best to update to the new schema. You can try to update all your old xslt files with this: http://our.umbraco.org/projects/developer-tools/xsltupdater-for-umbraco.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft