Exploring some ideas here internally and reaching out to this lovely community to get some feedback.
Essentially, we've got a couple of vorto properties for a specific content type and would love to do some copy/paste from one language to another on editor's request (so doesn't have to do it automagically).
I was wondering about the best option to implement, and we're thinking about either using the "Save, Save & publish" dropdown button (which would more or less hide the functionality) or add it as a standalone extra button (next to preview button for example)
Oh, it will involve launching a dialog to specify some settings before the actual action is performed.
Any tips? Caveats? Do's or don't's? Yay's or nay's, any feedback appreciated!
For you will want to intercept the content edit view :
That will look something like this :
angular.module('umbraco.services').config([
'$httpProvider',
function ($httpProvider) {
$httpProvider.interceptors.push(['$q','$injector',function ($q,$injector) {
return {
'request': function (request) {
// Redirect any requests to built in content delete to our custom delete
if (request.url === "views/content/edit.html") {
request.url = '/App_Plugins/YourPluginFolder/views/content-edit.html';
}
return request || $q.when(request);
}
};
}]);
}]);
This will intercept all calls to the content edit view and replace the edit view with your own.
In your own you can copy the markup of the built in edit view and add your button. Also you need to change the ng-controller directive to point to your own controller.
Then in your controller you can do this :
angular.module('umbraco').controller('YourControllerName',
['$scope', '$controller',
function ($scope, $controller) {
// inherit core edit controller
angular.extend(this, $controller('Umbraco.Editors.Content.EditController', { $scope: $scope }));
// add your logic for handling button click here
}]);
This will make the scope and functions from the core controller available in your controller...like inheriting a class in C#. So all core functionality keeps working.
Only downside is that when you upgrade umbraco it's possible that it breaks because the core view can change.
no, user initiates the action, and has to provide some settings (in our specific example, specity what source and destination language through a custom view - don't see any issues here) and perform the actual action
Adding custom actions on content edit page (not custom context menu)
Hi all,
Exploring some ideas here internally and reaching out to this lovely community to get some feedback.
Essentially, we've got a couple of vorto properties for a specific content type and would love to do some copy/paste from one language to another on editor's request (so doesn't have to do it automagically).
I was wondering about the best option to implement, and we're thinking about either using the "Save, Save & publish" dropdown button (which would more or less hide the functionality) or add it as a standalone extra button (next to preview button for example)
Oh, it will involve launching a dialog to specify some settings before the actual action is performed.
Any tips? Caveats? Do's or don't's? Yay's or nay's, any feedback appreciated!
--Dirk
Hi Dirk,
You can do this using angular interceptors. Read this blog by Matt Brailsford to get the idea : http://24days.in/umbraco-cms/2015/umbraco-7-back-office-tweaks/
For you will want to intercept the content edit view :
That will look something like this :
This will intercept all calls to the content edit view and replace the edit view with your own.
In your own you can copy the markup of the built in edit view and add your button. Also you need to change the ng-controller directive to point to your own controller.
Then in your controller you can do this :
The important line here is
This will make the scope and functions from the core controller available in your controller...like inheriting a class in C#. So all core functionality keeps working.
Only downside is that when you upgrade umbraco it's possible that it breaks because the core view can change.
Dave
I get the gist, was reading up on Matt's article, just was exploring some ideas and options before we decide to go with route a or b
Copying the view is a trade off indeed, but we intend to do it anyway for other parts of the system, so we're aware of the possible upgrade trap.
But this idea can also be applied to the Vorto view. So you will have the option in the vorto editor.
This way you don't override any core things, but only Vorto...maybe it's easier to maintain when doing upgrades
Agree, and we already have a custom vorto implementation (until Matt wants to merge in the PR (Are you listening Matt?)) ;-)
so the action you want is something the user has to ask for or be notified of??
My temptation would be to have it as a separate "thing", ie button , and actions, because then you can specify your own rules
no, user initiates the action, and has to provide some settings (in our specific example, specity what source and destination language through a custom view - don't see any issues here) and perform the actual action
is working on a reply...