November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
One way could be, hook On Saving Events and Cancel Saving on validation
http://world.episerver.com/blogs/K-Khan-/Dates/2015/5/hook-into-catalog-events/
Regards
/K
Thanks for the reply :) That was one of my first ideas and in theory it would work. One question though is that to add a varient to a node, I'm physiucally dragging varients over and using the link option when prompted, this updates and moves it automatically (reference here http://prntscr.com/8bt8go).
Does linking still call the published event even though I don't need to actually hit the publish button?
Hi,
With this approach, you will add handler for SavingContent (Not publishing events)
http://world.episerver.com/documentation/class-library/?documentId=cms/7/bcf6284c-22d0-5375-5b15-142b35138eb0
Regards
/K
Changes to Relations/Associations between nodes and entries can be listened via CatalogEventListenerBase http://world.episerver.com/documentation/Class-library/?documentId=commerce/8/1E7D1BBB . What I think that might work for you is:
- Implement an implemenation of CatalogEventListenerBase
- Override AssociationUpdating and RelationUpdating methods
- In these method, check if the changes satisfy your conditions or not.
Those events are ecf events, they work with DTO (CatalogRelationDto and CatalogAssociationDto).
Regards.
/Q
That looks promsiing, lathoguth my codes not getting hit. How do i register it?
I've got this
public class MyCatalogEventListenerBase : CatalogEventListenerBase { public new void AssociationUpdating(object source, AssociationEventArgs args) { var variant = source as GameVariation; var boo = variant != null; } public new void RelationUpdating(object source, RelationEventArgs args) { var variant = source as GameVariation; var boo = variant != null; } }
and I also added in a structure map config but still nothign, is there somethign i'm missing?
container.For<CatalogEventListenerBase>() .Use(ctx => new MyCatalogEventListenerBase());
Hi,
You are using "new". You should use "override" instead.
P/s: And you can use the attribute registration: [ServiceConfiguration(typeof(CatalogEventListenerBase)]
/Q
Perfect, thanks for your help. That's got it working. Last question though.. I can now do look-ups and prevent extra nodes, is there a recommened way that I can feed this back to the user? I assume I'd write somethign like this :
public override void RelationUpdating(object source, RelationEventArgs args) { var variant = source as GameVariation; var boo = variant != null; if (beep == NotUnderAnotherNode()) base.RelationUpdating(source, args); else // Display Error Somehow }
In the CMS I'd use soemthig like IValidate to return a ValidationError, any suggestions?
Hey, we have a requirement where we can have a selection of nodes, foir a rough example say we call them:
10% Discount
20% Discount
Content editors can drag varients under the node they want the discount to be applied and associate them. they will not live directly under these nodes.
What is the best way to prevent content editors from being able to drag a varient under more than one of these node? E.g. if variant one, has had an association added to it under the 10% discount node, if a content editor tries to additionally create a second association under 20% discount they should get some form of warning.
Thanks!
Jon