leekelleher / umbraco-contentment

Contentment for Umbraco - a state of happiness and satisfaction
https://marketplace.umbraco.com/package/umbraco.community.contentment
Mozilla Public License 2.0
157 stars 72 forks source link

GetCurrentContentId() always null #417

Closed woodi123 closed 2 weeks ago

woodi123 commented 3 weeks ago

Which Contentment version are you using?

4.7.0

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

13.5.1

Bug summary

I'm trying to access contextual data in a custom data source for a data list (as explained here: https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/data-list.md). I Got the following line inside the GetItems-method:

var currentId = _contentmentContentContext.GetCurrentContentId(out bool isParent);

When i click a node in the content tree that has a property using my data list the variable currentId is always null. Seems like the current request url is /umbraco/backoffice/umbracoapi/content/GetEmptyByKeys (which contains no query information about the current node).

Am i missing something? How can i get the current node? Thanks!

Steps to reproduce

Try accessing contextual data using _contentmentContentContext.GetCurrentContentId() inside GetItems() of a custom data source.

Expected result / actual result

Get current node.

Do you have Umbraco ModelsBuilder enabled?

What browsers are you seeing the problem on?

No response

woodi123 commented 2 weeks ago

Nevermind, i can take parentId from the posted data of GetEmptyByKeys to get the node id.

leekelleher commented 2 weeks ago

@woodi123 Cool, thanks for the follow up. (I hadn't had chance to investigate it yet). I'll close this off. 👍