Umbraco 设置自定义发布日期,但如果为';它是空的
我正在尝试创建一个自定义发布日期,因为用户希望将其用作发布日期和排序。该日期也将显示在页面上 以下是我想要的:Umbraco 设置自定义发布日期,但如果为';它是空的,umbraco,umbraco7,Umbraco,Umbraco7,我正在尝试创建一个自定义发布日期,因为用户希望将其用作发布日期和排序。该日期也将显示在页面上 以下是我想要的: 用户可以输入日期 日期可以为空(表示将立即发布) 它必须使用该日期进行排序 日期必须设置为UTC时间,因此它对世界上的每个人都是平等的 我绝望了,我不知道该怎么做 以下是我迄今为止尝试过的:我发现了一个简洁的小插件,它在输入字段旁边显示用户的当前UTC时间,这样用户就知道了他们的UTC时间。我将其修改为始终在输入字段中输入当前日期: var timer = setInterval(fu
var timer = setInterval(function () {
var date = $(".custom-date").val();
if (date === "") {
$(".custom-date").focus();
$(".custom-date").click();
$(".custom-date").trigger("click");
//the date has now been set on the input field
} else if (date !== "") {
var newDate = new Date(date);
var stringDate = newDate.getFullYear() + "-" + ('0' + (newDate.getMonth() + 1)).slice(-2) + "-" + ('0' + (newDate.getDate() - 1)).slice(-2) + " " + ('0' + (newDate.getHours() - offset)).slice(-2) + ":" + ('0' + newDate.getMinutes()).slice(-2) + ":" + ('0' + newDate.getSeconds()).slice(-2);
$(".custom-date").val(stringDate);
angular.element(".custom-date").scope().$apply(function () {
angular.element(".custom-date").scope().datetimePickerValue = stringDate;
});
clearInterval(timer);
}
}, 1000);
是的,这看起来像很多。。。不,它不起作用。我在元素上执行focus/click/trigger,因为这样会自动将时间设置为用户的本地时间。然后我将其转换为UTC时间(偏移量是UTC时间偏移量)。然后我将日期应用于元素的作用域,并且值在$scope和视图中都得到更新(我实际上可以看到它)
但是,当我点击SaveandPublish时,日期被重置(在数据库中为空)。只有当我实际单击输入字段并选择一个新日期时,它才会实际更新它。我喜欢这种方法,因为我100%地控制着它,所以有可能吗?在作用域上设置新日期似乎不会触发实际的“已选择新日期”
或者,我在这里有我的剃须刀代码:
//selection is all my elements/nodes
selection.OrderByDescending(x => x.GetProperty("publishDate") != null).ThenByDescending(x => x.GetPropertyValue("publishDate")).Where(x => x.GetPropertyValue<DateTime>("publishDate") < DateTime.UtcNow);
//选择是所有我的元素/节点
selection.OrderByDescending(x=>x.GetProperty(“publishDate”)!=null)。然后ByDescending(x=>x.GetPropertyValue(“publishDate”)。其中(x=>x.GetPropertyValue(“publishDate”)
显然,在角度事件被触发之前,我至少需要将其称为:
$(".custom-date").trigger("click");
$(".custom-date").change();
所以我在设定新日期后就这么做了,现在它开始工作了。显然,在角度事件被触发之前,我至少需要称之为:
$(".custom-date").trigger("click");
$(".custom-date").change();
所以我在确定了新的日期后就这么做了,现在一切正常了