Access custom app plugin data in IPublishedContent context
I was wondering if there is an easy way to access the data (if available) of a custom plugin, which was added to the content of a page. So in my base template I would invoke my html action with something like this
@Html.Action("MethodName", "ControllerName", new { node = CurrentPage })
In my controller I would like to first check if a custom plugin is added to this specific page and if so get the data of this plugin.
I know that it's stored somewhere in node.Properties.Value (as IPublishedContent) but I assume there must be an easier way to access this. Unfortunately I didn't find anything in the official documentation.
Perhaps someone can point me in the right direction?
var editor = node.GetProperty("asideContent");
if (editor != null)
{
var editorString = editor.Value.ToString();
if (editorString.Contains("APP_PLUGIN_ALIAS"))
{
var parsed = JObject.Parse(editor.Value.ToString());
var controls = parsed["sections"][0]["rows"][0]["areas"][0]["controls"];
if (controls.First != null)
{
foreach (var item in controls.Children())
{
var alias = item["editor"]["alias"].ToString();
if (alias != null && alias == "APP_PLUGIN_ALIAS")
{
var element = JsonConvert.DeserializeObject<CUSTOM_MODEL>(item["value"].ToString());
}
}
}
}
}
Access custom app plugin data in IPublishedContent context
I was wondering if there is an easy way to access the data (if available) of a custom plugin, which was added to the content of a page. So in my base template I would invoke my html action with something like this
In my controller I would like to first check if a custom plugin is added to this specific page and if so get the data of this plugin.
I know that it's stored somewhere in
node.Properties.Value
(as IPublishedContent) but I assume there must be an easier way to access this. Unfortunately I didn't find anything in the official documentation.Perhaps someone can point me in the right direction?
I've found this post: https://our.umbraco.com/forum/using-umbraco-and-getting-started/79220-get-a-members-custom-property but I'm not sure if this fits my needs. When I try to implement it, it always returns null.
Ok, so I think I found a workaround:
Still not really working though, because I have to know in which property the plugin is added ...
is working on a reply...