Copied to clipboard

Flag this post as spam?

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


  • Sean Dooley 289 posts 528 karma points
    May 07, 2020 @ 14:22
    Sean Dooley
    0

    Additional properties null when rendering

    I've setup a couple of grid editors using DTGE. When editing the values are persisting as expected.

    When rendering on the front-end, all but the first property is NULL.

    For example

    Video

    • Media | Media Picker
    • Aspect Ratio | Dropdown (value set in the CMS but NULL when rendering)
    • Title | Textstring (value set in the CMS but NULL when rendering)

    Any help would be appreciated.

    @inherits UmbracoViewPage<IPublishedElement>
    
    @{
      const string altTextAlias = "altText";
      const string aspectRatioAlias = "aspectRatio";
      const string mediaAlias = "videoId";
    
      var media = Model.Value(mediaAlias);
    
      if (media == null)
      {
        return;
      }
    
      var aspectRatio = Model.Value(aspectRatioAlias, fallback: Fallback.ToDefaultValue, defaultValue: "16x9");
      var altText = Model.Value(altTextAlias, fallback: Fallback.ToDefaultValue, defaultValue: null);
    }
    
    <div class="grid-section__media flex">
      <div class="grid-section__video flex justify-center">
        <div class="video-embed-wrapper">
          <div class="video-embed aspect-ratio aspect-ratio--@aspectRatio aspect-ratio--loading" data-video-embed="@media">
            <figure class="aspect-ratio__object flex fade-out" data-video-embed-object="">
              <img class="object-fit-cover w-100" data-src="//i3.ytimg.com/vi/@(media)/maxresdefault.jpg" alt="@altText">
              <div class="absolute center">
                <div class="video-embed__play cp">
                  <div class="icon  icon--play">
                    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="30" viewBox="0 0 24 30">
                      <g fill="none" fill-rule="evenodd" transform="translate(-14 -10)">
                        <mask id="h" fill="#fff">
                          <path d="M14.583 10.417v29.166L37.5 25z"></path>
                        </mask>
                        <path fill="#000" d="M0 0h50v50H0z" mask="url(#h)"></path>
                      </g>
                    </svg>
                  </div>
                </div>
              </div>
            </figure>
          </div>
        </div>
      </div>
    </div>
    

    Umbraco 8.5.4 DTGE 1.1.0

Please Sign in or register to post replies

Write your reply to:

Draft