rolfis / MediaContentUsage

Creates and shows relations between Media and Content in Umbraco 7.x. Tested in 2021 with 7.15.7. Does not handle nested content.
4 stars 0 forks source link

Does this work with Archetype? #1

Open jbreuer opened 10 years ago

jbreuer commented 10 years ago

Hello,

Normally I would ask this question on the forum, but the package doesn't have forum on our: http://our.umbraco.org//projects/backoffice-extensions/media-content-usage

Does this package also work if the media picker is part of Archetype? https://github.com/imulus/Archetype

rolfis commented 10 years ago

Is it possible for anyone to create a new forum for their projects?

The short answer to your question is "no". Right now, it's searching the cmspropertydata table with some SQL and combining all property values to search for media node ids in certain datatypes where media is expected in single or comma separated format, or in the rel="\d+" regular expression for Richtext Editor.

I'm not exactly sure how Archetype works internally but the DataType is what get's written to cmspropertydata in the db.

In this quick example that I tried: { "fieldsets":[ { "properties":[ {"alias":"title","value":"My title"}, {"alias":"intro","value":"My intro text"}, {"alias":"image","value":1056} ], "alias":"imageCarousel" }, { "properties":[ {"alias":"image","value":1055}, {"alias":"title","value":"Another title"}, {"alias":"intro","value":"Another intro text with another image..."} ], "alias":"imageCarousel" } ] }

the alias "image" is a Media Picker datatype, but the JSON here is not expressing that in any way. If there were an additional "datatypeid" attribute along with "alias" and "value", I guess it could be pretty easy to check for this in the property data and then parse out the "value" to relate to a Media node.

jbreuer commented 10 years ago

If you go to your projects you can see a forums button. f1 If you click on that there is an add new forum link. f2 I'll ask @kgiszewski if he can give some more info about Archetype.

For now I won't use this package because it might say that the media isn't used anywhere while it might be selected with Archetype. If there is a solution it might be nice to also add that to the PR you're working on.

kgiszewski commented 10 years ago

Re: Archetype. In order to have the leanest possible data stored in the cache, the datatype ID is just kept in the config (cmsPrevalues). You could crawl through that table to find archetypes that use media picker. We've also found that tracking datatypes by the ID (integer) is flawed in multi-staging environments. Rather the datatype GUID appears more robust and therefore that's what we use.

Overall it would be very difficult to account for all current and future datatypes that might contain references to media items. (i.e. the future grid editor, mntp, media picker, archetype, etc.)

And to make matters even more fun, Archetypes can be nested inside other Archetypes which would prove difficult to parse.

I definitely see a need to know if a piece of media is being referenced by content. I'm just not sure of the best way to go about it without keeping explicit back-references (i.e. the media itself knows where it's used).

rolfis commented 10 years ago

Thanks @jbreuer I finally found the forum parts for projects, so I've added a forum there now.

Yes, there are some discussions now in the pull request about media and content relations, that's good. :) I think Per also talked about the future grid editor and the challenges about relations there.

But right now for the Archetype use case, thanks @kgiszewski for the input, maybe it's hard to provide a simple solution just by adding some sql... But then again, maybe it's possible to crawl cmsDataTypePreValues and look for archetypeConfig and look for dataTypeGuids that should be searched for media...

I wasn't aware of the id flaw in multistage, that's a good point for not using them but instead guid.