Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Umbraco Content data source doesn't work on member #184

Closed
1 task done
bjarnef opened this issue Nov 8, 2021 · 10 comments
Closed
1 task done

Umbraco Content data source doesn't work on member #184

bjarnef opened this issue Nov 8, 2021 · 10 comments
Assignees
Labels
umbraco A concern for Umbraco

Comments

@bjarnef
Copy link

bjarnef commented Nov 8, 2021

Which Contentment version are you using?

1.4.4

Which Umbraco version are you using? For example: 8.14.1 - don't just write v8

8.13.1

Bug summary

Not sure if this is a bug in Contentment as it is also the behaviour with MNTP.

When using Umbraco Content data source on a member, the data list doesn't show any data. This is probably because it doesn't know about the context. I can probably use $root instead of $site when we know only a single site node is used:

image

I suggested this some time ago to make MNTP work on Media and Member types, when current section is not Content section: umbraco/Umbraco-CMS#10049

Steps to reproduce

Create a datatype using Data List and Umbraco Content as datasource.
Specify Xpath query using $site and add a property to a member type using this datatype.

When "Add" on member property no content is shown in overlay.

Expected result / actual result

No response

Do you have Umbraco ModelsBuilder enabled?

  • Yes, it is enabled.

What browsers are you seeing the problem on?

No response

@bjarnef bjarnef added the bug-report Something isn't working label Nov 8, 2021
@bjarnef
Copy link
Author

bjarnef commented Nov 8, 2021

Using $root solve it in the use-case though :)

@leekelleher
Copy link
Owner

@bjarnef Tricky to say whether it's a bug or by design, as Umbraco's UmbracoXPathPathSyntaxParser.ParseXPathQuery method is attempting to replace the XPath's $ tokens with the ID of the closest content item. Then when used on a member, there is no context of the content to use.

Here's how the Umbraco Content data-source is attempting to get the contextual ID;
https://github.com/leekelleher/umbraco-contentment/blob/1.4.4/src/Umbraco.Community.Contentment/DataEditors/DataList/DataSources/UmbracoContentDataListSource.cs#L80

...and here's how Umbraco's UmbracoXPathPathSyntaxParser replaces the tokens;
https://github.com/umbraco/Umbraco-CMS/blob/release-8.6.1/src/Umbraco.Core/Xml/UmbracoXPathPathSyntaxParser.cs#L70-L100

Like you say, $root will always work, as it doesn't need a contextual ID.

I'm not sure what I could do to make it work in the Media/Members sections. Open to suggestions.

Best I can do at the moment is to make a note of it in the known issues on the README.

@leekelleher leekelleher added umbraco A concern for Umbraco and removed bug-report Something isn't working labels Nov 8, 2021
@bjarnef
Copy link
Author

bjarnef commented Nov 8, 2021

@leekelleher yeah, Media and Member section need the contextual ID, but not sure what the request returns here, when not request is made from content section.

In case you only have a single root node in content section it could specifically use this or when request is made from media/member section. However I am note sure what happens if the picker is opening in infinite mode in media/member. I think the editorState , e.g. editorState.current as in this PR umbraco/Umbraco-CMS#10966

Sometimes you may have multiple root nodes, but actually only a single site node. Not sure there´s a good way to cover this scenario.

@bjarnef
Copy link
Author

bjarnef commented Nov 11, 2021

@leekelleher with "Umbraco Content" data source we can set the parent node, but is there a way to limit to a specific node type like MNTP?

E.g. I have this structure:

  • Brand Archive
    • Brand A
      • Brand Location A1
      • Brand Location A2
    • Brand B
      • Brand Location B1
      • Brand Location B2

Using the XPath $site//brandArchive shows both "Brand A + B" and "Brand Location" nodes, but I wan't the filter to only select "Brand Location" nodes.

Or would I need to add a custom data source for this?

@leekelleher
Copy link
Owner

Using the XPath $site//brandArchive shows both "Brand A + B" and "Brand Location" nodes, but I wan't the filter to only select "Brand Location" nodes.

@bjarnef From the structure you mentioned, that doesn't sound correct. The "Umbraco Content" data-source should only list the direct child nodes, not the descendants. 😕 So I'm not sure why the "Brand Location" nodes are being displayed.

With your question about filtering on DocType, it currently doesn't have that feature, but it could be a potential feature request. 😀

In the meantime, you could try the "Umbraco Content by XPath" data-source (unless if you can't, e.g. Media/Members)? or a custom data-source.

@bjarnef
Copy link
Author

bjarnef commented Nov 11, 2021

@leekelleher yeah, however I don't want to show direct children more the descendant "Brand Location" nodes. Or is is okay the show "Brand" nodes, they should just be disabled.

I tried with $site//brandArchive/brandEntity but only shows children og first brand.

It doesn't seem I have a ""Umbraco Content by XPath" data-source as this it Contentment v1.4.4 - maybe it was added later?

I can probably implement a custom data source and include "Brand Location" nodes. Maybe there a "Group" option? It could be nice the group these by parent node, e.g. similar to this picker in Vendr (not necessarily with the option to "select parent / select all"), but more the grouping. Could be useful e.g. in a "Region Picker" 😁😎

image

@leekelleher
Copy link
Owner

It doesn't seem I have a ""Umbraco Content by XPath" data-source as this it Contentment v1.4.4 - maybe it was added later?

It was originally added as a hidden data-source in v1.4.0 - see the secret notes 🤫 part on how to enable it. It was latest unhidden (available for all) in v2.1.0, and the Group property was added too.

re: native grouping, I did start work on Data List grouping, see discussion #90 - but the AngularJS parts got quite tricky with some of the list-editors.

@bjarnef
Copy link
Author

bjarnef commented Nov 11, 2021

Cool, I must have missed that part and have mostly worked with Contentment v1.
Would be great to use a newer version of Contentment, but for now the project is still on Umbraco v8.13.1

For now I think a custom data source using Internal og External examine index may be good enough 😊

@leekelleher
Copy link
Owner

The main reason for the Umbraco dependency bump was to do with the <umb-icon> directive, (and v8.14 was the latest at the time). Always tricky for a package developer to balance progress/enhancements with maintenance/support. 😬

For now I think a custom data source using Internal og External examine index may be good enough 😊

Feel free to reuse what you need from the Examine data-source - if it helps?
e.g. https://github.com/leekelleher/umbraco-contentment/blob/dev/v2.x/src/Umbraco.Community.Contentment/DataEditors/DataList/DataSources/ExamineDataListSource.cs

@leekelleher
Copy link
Owner

Closing off this issue, (as per the original query). As mentioned above, #184 (comment), the "Umbraco Content" data-source was (limited) designed to work within the Content section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
umbraco A concern for Umbraco
Projects
None yet
Development

No branches or pull requests

2 participants