Beispiel #1
0
        private void InitPublishedContent()
        {
            if (!_publishedContentInitialized)
            {
                _publishedContentInitialized = true;

                if (UmbracoContext.Current == null)
                {
                    return;
                }

                if (Udi.TryParse(_linkItem.Value <string>("udi"), out _udi))
                {
                    _content = _udi.ToPublishedContent();
                    _id      = _content?.Id;
                }
                else
                {
                    var helper = new UmbracoHelper(UmbracoContext.Current);

                    // there were no Udi so let's try the legacy way
                    _id = _linkItem.Value <int?>("id");

                    if (_id.HasValue)
                    {
                        bool isMedia = _linkItem.Value <bool>("isMedia");

                        if (_linkItem.Value <bool>("isMedia"))
                        {
                            _content = helper.TypedMedia(_id.Value);
                        }
                        else
                        {
                            _content = helper.TypedContent(_id.Value);
                        }
                        SetUdi();
                    }
                }
            }
        }