November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
If you want to set the same value (e.g. Daily News) for each newly created block then set the properties to value under SetDefaultValues() method.
public override void SetDefaultValues(ContentType contentType)
{
base.SetDefaultValues(contentType);
this.DeliveryAPIKey = "Daily News";
}
If you want to set a property value with the same name of the created block, then you can assign the Block/Page name in the property as below:
public virtual string DeliveryAPIKey => this.Name;
I thought this was the proper way at first too, but it seems this property is set to some kind of ID.
When I am debugging and I attempt to get the value of this string, it shows the value in this image: https://imgur.com/h90i96v
This seems to be an ID for the delivery feed.
It does actually work setting the DeliveryAPIKey value to this through the SetDefaultValues() method, and then the block will have the "Daily News" feed just fine.
However, is this ID something that might change in the future?
I thought then it would be best to be able to retrieve this ID through code, as to not have any funny surprises if that happens.
I have not found a way to do this yet, though.
The approach which you described will work when the page/block will load.
Another way we can update content through the scheduled job.
foreach (var block in allBlocks)
{
var myBlock= block.CreateWritableClone<NewsBlock>();
myBlock.DelevriyApiKey= GetDeliveryKey(nameof(DeliveryKeyAPI));
_contentRepository.Save(myBlock, SaveAction.Publish,AccessLevel.NoAccess);
}
FIXED!
This is how you do it:
1. Find the API-key of the delivery you wish to use as your default. You'll find this in the Content Intelligence interface, under Engage -> Deliveries.
2. Put this key in, for example, your appsettings like so:
Keep in mind that this is NOT a replacement for your ApiToken that is used for the package in general, but as an extra custom value.
3. In your model or controller, retrieve the value like so:
4. Profit. That's it.
Now your block will use whatever delivery method you chose as the default one.
Hello,
I am pretty new to Episerver development, and I am working with Content Recommendations.
Right now I am trying to make it so every new Content Recommendations block by default will have the same delivery-source (if that makes sense).
So we have a couple of widgets set up, and I'd like the block by default to be set to "Daily News", for example.
In the SetDefaultValues() method, I've written:
this.DeliveryAPIKey = "Daily News";
(as I'm not verified yet, I am unable to upload image of my code) :(
I am aware this is not correct, but I do not understand how I set this string to one of our delivery channels.
Is there a good way of doing this?
Thank you in advance :)