/// <summary>
        ///     Get the standard value for the field.  If the field is the Layout field (__renderings), it attempts to use base
        ///     layouts. Otherwise, it passes the call on to the inner provider, which is usually the built-in standard values
        ///     provider.
        /// </summary>
        /// <param name="field">
        ///     The field.
        /// </param>
        /// <returns>
        ///     The standard value
        /// </returns>
        public override string GetStandardValue(Field field)
        {
            try
            {
                if (field.IsLayoutField() && _baseLayoutValidator.ItemSupportsBaseLayouts(field.Item))
                {
                    if (_settings.AlwaysCheckForCircularReference &&
                        _baseLayoutValidator.HasCircularBaseLayoutReference(field.Item))
                    {
                        _log.Warn(
                            "Circular Base Layout reference detected on item {0}. Aborting base layout composition.",
                            field.Item.Paths.Path);
                    }
                    else
                    {
                        var layoutValue = _baseLayoutValueProvider.GetBaseLayoutValue(field.Item);
                        if (!string.IsNullOrEmpty(layoutValue))
                        {
                            return(layoutValue);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Error getting layout value.");
            }

            return(_innerProvider.GetStandardValue(field));
        }
Beispiel #2
0
        public string GetBaseLayoutValue(Item item)
        {
            var value = _cache.GetLayoutValue(item);

            if (string.IsNullOrWhiteSpace(value))
            {
                value = _innerProvider.GetBaseLayoutValue(item);
                if (!string.IsNullOrWhiteSpace(value))
                {
                    _cache.AddLayoutValue(item, value);
                }
            }

            return(value);
        }