So, I'm developing this custom backoffice section for a client, but the experience of writing a custom plugin to Umbraco is (from my current perspective) one of the worst developer experiences I've had.. Maybe I'm doing something horrible wrong, I really hope that I am.
When making the smallest possible chance to the view, the changes aren't displayed on the screen. Sometimes it's enough to rebuild and refresh the page, sometimes it's enough to touch web.config and force the app-pool to recycle (running Umbraco from visual studio which should be supported as per the documentation). And sometimes I just furiosuly refresh the page and voila! my change appears
It seems like my package.manifest aren't loading the relevant javascript to the leads.html view. As the browser console tells me: "The controller with name 'Rexolution.GodMode.LeadsController' is not registered
I've tried to put the javascript inside a script-tag right in the leads.html view, but that doesn't allow me to register the controller either.
PLEASE, if you are a package developer, tell me or guide me through your workflow. Because I'm pulling my hair out right now........
[Tree("rexelGodMode", "rexelGodModeTree", TreeTitle = "God mode", SortOrder = 1)]
[PluginController("RexelGodMode")]
public class GodModeTreeController : TreeController
{
protected override MenuItemCollection GetMenuForNode(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))] FormDataCollection queryStrings)
{
// this tree does not support any menu item collections
return new MenuItemCollection();
}
protected override TreeNodeCollection GetTreeNodes(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))] FormDataCollection queryStrings)
{
// this tree doesn't support rendring more than 1 level of tree nodes
if (id != "-1")
throw new NotSupportedException();
// create our node collection
var nodes = new TreeNodeCollection();
// add tree nodes, each node representing
nodes.Add(CreateTreeNode("leads", "-1", queryStrings, "Leads", "icon-wallet", false, $"/rexelGodMode/rexelGodModeTree/leads"));
return nodes;
}
}
'use strict';
(function () {
//create the controller
function leadsController($scope) {
console.log('hello from the leads controller');
};
//register the controller
angular.module("umbraco").controller('Rexolution.GodMode.LeadsController', leadsController);
})();
When building custom apps/plugins for Umbraco, I always find it best to "Always Bump the ClientDependencyFramework version number" after each change. As you mentioned, sometimes it's enough to just reload, but most of the times it's not. Bumping CDF version always makes sure I am looking at the lastest changes.
Try that and let me know if it helps! :D
Cheers.
Explination of "Bumping the Client Dependency Framework version:"
In your /config/ClientDependency.config, up the version number by 1.
Umbraco heavily caches these files for production but if you run the site in Debug mode you should only have to refresh and empty cache in the browser to see the changes.
The debug attribute on Compilation in the web.config file should be true.
Developing package for Umbraco - workflow, errors, cannot load javascript etc etc
Please excuse my annoyed tone ;)
So, I'm developing this custom backoffice section for a client, but the experience of writing a custom plugin to Umbraco is (from my current perspective) one of the worst developer experiences I've had.. Maybe I'm doing something horrible wrong, I really hope that I am.
I've followed this tutorial from the docs: https://our.umbraco.com/documentation/Extending/Section-Trees/sections
The problem I'm running into is two-fold.
When making the smallest possible chance to the view, the changes aren't displayed on the screen. Sometimes it's enough to rebuild and refresh the page, sometimes it's enough to touch web.config and force the app-pool to recycle (running Umbraco from visual studio which should be supported as per the documentation). And sometimes I just furiosuly refresh the page and voila! my change appears
It seems like my package.manifest aren't loading the relevant javascript to the leads.html view. As the browser console tells me: "The controller with name 'Rexolution.GodMode.LeadsController' is not registered
I've tried to put the javascript inside a script-tag right in the leads.html view, but that doesn't allow me to register the controller either.
PLEASE, if you are a package developer, tell me or guide me through your workflow. Because I'm pulling my hair out right now........
My relevant files are as follows:
package.manifest
GodModeTreeController.cs
leads.html
leads.controller.js
File structure
When building custom apps/plugins for Umbraco, I always find it best to "Always Bump the ClientDependencyFramework version number" after each change. As you mentioned, sometimes it's enough to just reload, but most of the times it's not. Bumping CDF version always makes sure I am looking at the lastest changes.
Try that and let me know if it helps! :D Cheers.
Explination of "Bumping the Client Dependency Framework version:" In your /config/ClientDependency.config, up the version number by 1.
Thanks alot Dennis, I will try it out!
EDIT: It workes, and now my 'hello from leadsController' get's printed to the browser console.
Thank you alot Dennis, you deserve a high five and a beer. If you're even in Jönköping, Sweden - gimme a holla!
Hi Mathias,
Are you sure you are working in debug mode ?
Umbraco heavily caches these files for production but if you run the site in Debug mode you should only have to refresh and empty cache in the browser to see the changes.
The debug attribute on Compilation in the web.config file should be true.
https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-enable-debugging-for-aspnet-applications?view=vs-2019
Hey Garthar, the debug option is set to true, I just checked
For point 1 - when working with AngularJS views in the backoffice, I'd recommend opening your browser's dev tools and disabling the cache.
Further details here: https://stackoverflow.com/a/7000899/12787
I found that Chrome would aggressively cache HTML requests, (more than CSS or JS requests) ... so this is more your browser doing it than Umbraco.
is working on a reply...