mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 17:08:47 +08:00
When chaining tokens, if nothing was selected in a CPF, evaluation would log (#8763)
and error because it would seek an item out of the range of the array.
This commit is contained in:
parent
90dc993e83
commit
c7d10fd0be
@ -3,6 +3,7 @@ using Orchard.ContentManagement;
|
||||
using Orchard.Events;
|
||||
using Orchard.ContentPicker.Fields;
|
||||
using Orchard.Localization;
|
||||
using NHibernate.Util;
|
||||
|
||||
namespace Orchard.ContentPicker.Tokens {
|
||||
public interface ITokenProvider : IEventHandler {
|
||||
@ -28,7 +29,10 @@ namespace Orchard.ContentPicker.Tokens {
|
||||
public void Evaluate(dynamic context) {
|
||||
context.For<ContentPickerField>("ContentPickerField")
|
||||
.Token("Content", (Func<ContentPickerField, object>)(field => field.Ids[0]))
|
||||
.Chain("Content", "Content", (Func<ContentPickerField, object>)(field => _contentManager.Get(field.Ids[0])))
|
||||
.Chain("Content", "Content", (Func<ContentPickerField, object>)(field => {
|
||||
var id = field.Ids.Any() ? field.Ids[0] : 0;
|
||||
return _contentManager.Get(id);
|
||||
}))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user