Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 24 2018 16:41

    leekelleher on develop

    Migration to UMCO - Updated th… (compare)

  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:22
    leekelleher edited #234
  • Jan 24 2018 16:20
    leekelleher edited #234
  • Jan 24 2018 16:03
    leekelleher labeled #234
  • Jan 24 2018 16:03
    leekelleher assigned #234
  • Jan 24 2018 16:03
    leekelleher opened #234
  • Jan 24 2018 15:39
    leekelleher unassigned #195
  • Jan 24 2018 15:39
    leekelleher unassigned #188
  • Jan 24 2018 15:39
    leekelleher unassigned #177
  • Jan 24 2018 15:39
    leekelleher unassigned #176
  • Jan 24 2018 15:39
    leekelleher unassigned #138
  • Jan 24 2018 15:39
    leekelleher unassigned #111
  • Jan 24 2018 15:39
    leekelleher unassigned #67
  • Jan 24 2018 15:39
    leekelleher unassigned #61
  • Jan 24 2018 15:39
    leekelleher unassigned #59
  • Jan 24 2018 15:39
    leekelleher unassigned #53
  • Jan 24 2018 15:39
    leekelleher unassigned #49
Matt Brailsford
@mattbrailsford
i had an example where I have a "link" model, which when mapping from IPublishedContent grabs the Name / Url, but wanted it to handle UrlPicker model values too
James Jackson-South
@JimBobSquarePants
@mattbrailsford I'd have to check our exact logic.
Matt Brailsford
@mattbrailsford
guess we should really write some docs :D
James Jackson-South
@JimBobSquarePants
Yeah.... It's about time. There's so much power there but it's all in our heads

Ok so the current logic is.

  1. Check the property for processor attributes and capture them
  2. If non found add the default (UmbracoProperty)
  3. Then check for type based attributes and add
  4. Then check TypeParams in enumerables
  5. Then add core types.

As long as the processor ones resolve to your expected type they should overule anything found elsewhere.... Should.

Barry Fogarty
@BarryFogarty
[DittoDocTypeFactory] on my interface works great guys. :thumbsup: :thumbsup: Keep up the good work, and HAPPY CHRISTMAS :-)
Matt Brailsford
@mattbrailsford
:+1:
James Jackson-South
@JimBobSquarePants
:clap:
You too!
Barry Fogarty
@BarryFogarty
Guys sorry for the interruption, just following on from yesterday, can I use [DittoDocTypeFactory] on a picker-based property? Basically I'm trying to do a similar thing as I described yesterday, but this time the collection will be derived from an MNTP:
[UmbracoProperty("cards_Items", Order = 1)]     
[UmbracoPicker(Order = 2)]
[DittoDocTypeFactory(Order = 3)]
public virtual IEnumerable<ICard> Items { get; set; }
Matt Brailsford
@mattbrailsford
If you have jeavons value converters installed, don't think you need the picker attribute
Barry Fogarty
@BarryFogarty
Ah that could be it, I've just come one to this project and not checked that. Theoretically it should work though? As long as the picked nodes implement ICard?
Matt Brailsford
@mattbrailsford
Yup
Barry Fogarty
@BarryFogarty
It is installed but removing UmbracoPicker attribute doesnt change things - I have 3 items of type ICard but they are all null. When this executes on the doctype with the nested content property however, I can see the {CardProxy} type in the watch. In both cases though, the GetPropertyValue returns a list of IPublishedContent correctly.
Maybe its not being wired up correctly on my concrete type - anyway off to lunch will do more investitgations after. Cheers
Matt Brailsford
@mattbrailsford
Hmm, it may not work with virtual props
James Jackson-South
@JimBobSquarePants
That RelatedPagesAttribute code I posted yesterday works fine with picked items. Everything should work with virtual properties.
I never install the value converters.
They won't work in that scenario anyway since the value converters return type is IEnumerable<IPublishedContent>
Barry Fogarty
@BarryFogarty
I tried uninstalling the value converters but the result is the same, list items are instantiated but null. The raw value from my picker is now a CSV of node IDs. I think I'll just take another approach, thanks for having a look though
Lee Kelleher
@leekelleher
@dannylee_c_twitter Did you ever get any further with your XPathQuery processor? I've got to a point where I could use something like it. :smiley:
Dan Curtis
@dannylee_c_twitter
hey @leekelleher - sorry I didn't get any notifications from your message
here's the code:
public class XPathAttribute : DittoProcessorAttribute
    {
        private readonly string[] _currentItemIdentifiers = { ".", "$current" };
        private readonly string[] _currentSiteIdentifiers = { "$site" };
        private readonly string[] _currentPageIdentifiers = { "$currentPage" };

        private string _xPath;

        public XPathAttribute(string xPath)
        {
            _xPath = xPath;
        }

        public override object ProcessValue()
        {
            var umbracoContext = UmbracoContext.Current;
            foreach (var currentItemIdentifier in _currentItemIdentifiers)
            {
                if (_xPath.StartsWith(currentItemIdentifier))
                    _xPath = $"id({Context.Content.Id})" + _xPath.Remove(0, currentItemIdentifier.Length).EnsureStartsWith("/");
            }

            foreach (var currentPageIdentifier in _currentPageIdentifiers)
            {
                if (_xPath.StartsWith(currentPageIdentifier))
                    _xPath = $"id({umbracoContext.PageId})" + _xPath.Remove(0, currentPageIdentifier.Length).EnsureStartsWith("/");
            }

            foreach (var currentSiteIdentifier in _currentSiteIdentifiers)
            {
                if (_xPath.StartsWith(currentSiteIdentifier))
                    _xPath = $"id({Context.Content.Id})/ancestor-or-self::*[@level = 1]" + _xPath.Remove(0, currentSiteIdentifier.Length).EnsureStartsWith("/");
            }

            if (Context.PropertyDescriptor.PropertyType.IsEnumerableType())
            {
                var genericTypeDefinition =
                    Context.PropertyDescriptor.PropertyType.GetGenericArguments().FirstOrDefault();
                return umbracoContext.ContentCache.GetByXPath(_xPath).As(genericTypeDefinition);
            }

            return umbracoContext.ContentCache.GetSingleByXPath(_xPath).As(Context.PropertyDescriptor.PropertyType);
        }
    }
Still needs some Ditto project tests, as I'm using integration tests to test it my side
Lee Kelleher
@leekelleher
@dannylee_c_twitter Hey, sorry for the delay in replying - only just seen your message. Thanks so much for sharing. Would you be cool if we took this and work on it further - either for Ditto (or the Ditto Labs repo)?
Dan Curtis
@dannylee_c_twitter
yeah go for it, keep me updated!
Barry Fogarty
@BarryFogarty
QQ - Is there a way to call a core ditto processor from a custom one. I want to create a 'DictionaryFallbackProcessor' which essentially needs to call UmbracoDictionary(key) if the value passed in is null or empty. I'm currently just using UmbracoHelper.GetDictionaryValue(key) but was interest generally whether a pattern like this was possible.
Matt Brailsford
@mattbrailsford
Inherit it then override the ProcessValue method wrapping it in a null check
That's essentially what we do with AltUmbracoProperty processor, wrapping the regular UmbracoProperty processor
Barry Fogarty
@BarryFogarty
To answer my own question, I've seen how the Ditto MultiProcessor attribute does it here https://github.com/leekelleher/umbraco-ditto/blob/ac17fea47c3d2be3cbca63c10f373cb5312ab2a6/src/Our.Umbraco.Ditto/ComponentModel/Attributes/DittoMultiProcessorAttribute.cs - but in my use case its a lot simpler to just call my Dictionary helper directly.
Lee Cook
@leethomascook_twitter
Hi All, I managed to get integration tests working with ditto, by making two small visibility changes to the core. ( umbraco/Umbraco-CMS#1710 ) Thoughts? Good /bad idea?
Marko
@mkjovanov
Hey guys, I would like to add Ditto ModelFactory to my project so I don't have to do cast 'As' poco properties in .cshtml views. Can I achieve this with the "Ditto ModelFactory" package? http://nugetmusthaves.com/Package/Our.Umbraco.Ditto.ModelFactory and does anybody happen to have any examples?
Lee Kelleher
@leekelleher
@mkjovanov Don't use the DittoModelFactory - it was an experiment that didn't work out (I should kill off that NuGet package). Our recommendation is to use DittoViewdirective on your views/partials. If you need an example, check out this github repo: https://github.com/lars-erik/DittoDemoModelsBuilderified/blob/master/Dittoified/Views/umbTextPage.cshtml
@leethomascook_twitter I'm not sure how the Umbraco core amends impact Ditto.
(Just checking are you using DittoModelFactory? hoping you say no :wink:)
jayfive
@jayfive
Hi, I'm new to ditto. Just giving it a trial now. What I can't figure out is how to map multi node tree pickers. It looks like the usage has changed a bit from version to version. I'm currently working with v0.10. Can you point me in the right direction on how to get this working?
Marko
@mkjovanov
@leekelleher thanks Lee, I will take a look at the examples. Cheers!
James Jackson-South
@JimBobSquarePants
@jayfive The simplest way I find is to decorate the class that represents your picked object with [DittoPicker] then use the propert as IEnumberable<YourPickedClass> in the calling class.
jayfive
@jayfive
Thanks @JimBobSquarePants, although DittoPicker doesn't seem to exist anymore. I checked the upgrade logs and can see it's been replaced with UmbracoPicker. This looks like it's done the job. I can now get on with replacing GlassMapper with Ditto :)
James Jackson-South
@JimBobSquarePants
Yeah sorry, forgot the name had changed :smile:
Norbert Haberl
@nhaberl
Any plans for Ditto v1.0
James Jackson-South
@JimBobSquarePants
Yeah of course. Need to have achat about that actually.
Barry Fogarty
@BarryFogarty
Are there any docs or resources available about the Ditto cache? The OOB implementation seems quite restrictive - you don't seem to be able to cache 2 separate properties by Content ID for example. Maybe I'm using it wrong though.. It'd be good to be able to chain the CacheBy rules (Property Name AND Content ID for example). I'm hoping to write my own custom cache key builder but not sure where to start.
Gareth Wright
@garpunkal
I have to say, Ditto is awesome! I've used it on 3 projects now and it's literally a pleasure to use! Would love to see this integrated into the core! Any chance of that happening?
Gareth Wright
@garpunkal

What would be the best approach for accessing the IPublishedContent in your mapped POCO... For instance:

I have a "Link" POCO and I want to check if that link IsAncestorOrSelf or the current page.
Would it be safe to do the following?

[CurrentContentAs]
public virtual IPublishedContent PublishedContent { get; set; }

and then use the extension method for IsAncestorOrSelf or would there be a different approach that you'd recommend?

Lee Kelleher
@leekelleher
@garpunkal Sorry we missed your questions, haven't been on Gitter for a while...
re: Ditto in Umbraco core ... nope, never gonna happen.
Gareth Wright
@garpunkal
@leekelleher no problem, I'll still use regardless! :)
Lee Kelleher
@leekelleher
@garpunkal With accessing the IPublishedContent within your POCO... we do check if the POCO has a constructor with 1 parameter of IPublishedContent
so Ditto will pass that in, and your POCO can keep a local/private reference of it
Gareth Wright
@garpunkal
ah cool
Lee Kelleher
@leekelleher
I was trying to find a reference in our unit-tests to show you... but my github-foo is failing me ;-)