Issues with creating a Starter Kit - or "Creating and Packing up, Installing ... OH $&"^+!"£! [Updated]
Evening all,
:TL:DR:
Package Creation: On the initial creation of my starter kit certain files cannot be added due to the inherent limitations of the create package process;Thanks @Lee! :-D
Installation: on kit installation property fields are presented out of order from creation; subsequent content nodes and files are missing; templates will not maintain hierarchy [Updated]
Image Cropper is throwing errors on image submission
Long Version
I'm currently building a starter kit and am running into a few issues with different steps that I hope you can help me with?
- While I can easily manually create a settings node in the content tree - when I create the package I cannot select that node of course because it's at root level and NOT a child of the Homepage?
How can I add nodes like this into the package OR programmatically create them using a package action? The umbraco.tv package action pdf link is broken and while the package action samples page links to great information it's not that clear on where and how to add this to your project? I've even looked at the built in starter kit's on GitHub and can't quite see how to do this as none of these have a "settings" node?
Installation:
As stated above, there are definite discrepancies happening when the kit creation process happens, properties of document type properties seem to be missing their order or not copied into the kit?
Let me outline the steps I take to reproduce after creating the kit:
I install the kit into a new 7.3.4 instance
(for now) manually add the settings node to the content tree
Choose the Content page's "social links tab", which is simple series of text strings and the property fields are no longer in the order I created them in?
[NEW] I then switch to the Settings section and my Childpage templates are no longer children of the Masterpage template?
What can I do to ensure they stay in the order I created them?
Why are none of the other tab property fields out of order?
Why is the template hierarchy no longer applied?
certain files are actually missing from included folders I added in the package process
How can I specify a file to be included in the package as this seems to be ignored from the package process?
It's a JSON file specifically if you're wondering!
I figured ths one out as while the kit creation process will grab files in a folder specified, JSON files are ignored, as are SVG's; I added them manualy to the included files and all is well!
Image cropper
I've created a new data type to create a favicon and added all my sizes, including a default, and when I add an image to the property field in the content tree and hit save I receive this error:
This happens no matter which version of the starter kit I'm testing on, the original or the installed one - both were in a brand new Nuget Installation of Umbraco running in VSC 2015 on Win10 (16gbRAM, 128GB SSD) if that helps?
So, that's about all for now, and I'm happy to answer any questions you might have and show code privately. If you would need to see the starter kit itself please contact me directly.
I do hope I can get these resolved soon as possible since, for those that know me, I don't have any more hair to pull out!
I don't have an answer for you, but I am interested in whatever answers you get (I too am thinking of building a starter kit soon).
What version of Umbraco are you using (my assumption is the latest... 7.3.1)?
Also, since starter kits are really just a collection of files and a config file, I wonder if you might solve some of your issues by manually modifying the config file. Just a thought.
Also, perhaps it would be a good idea to create some tickets on issues.umbraco.org for each of the specific problems you've noticed. I would be interested in seeing a resolution as soon as possible, and that's one of the better ways of going about it (assuming the issues you are seeing are due to bugs).
Thanks to @LeeKelleher I've a solution for the first part of my question above:
Package Creation
Here's the snippet for any and all to use - please note, this will be updated in my instance yet it's the best start I can give back to the community!
using System;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Services;
namespace KIT.Helpers
{
public class CreateKitExtensions : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Saved += ContentService_Saved;
}
private static void ContentService_Saved(IContentService sender, SaveEventArgs<IContent> e)
{
//Make sure we're on Level 1 on all saves otherwise welcome to node hell
if (e.SavedEntities.All(x => x.Level != 1)) return;
//The ContentService acts as a "gateway" to Umbraco data for operations which are related to Content.
var service = ApplicationContext.Current.Services.ContentService;
//We always know the root is id -1 - let's find her children
var rootNodeChildren = service.GetChildren(-1);
// check if the root node's children has a node with the Control Panel's doctype
if (!rootNodeChildren.Any(x => x.ContentType.Alias.InvariantEquals("KIT_Global__Options")))
{
// if not, then create the Control Panel node
MakeControlPanel();
}
}
private static void MakeControlPanel()
{
try
{
var service = ApplicationContext.Current.Services.ContentService;
var controlPanel = service.CreateContent("Control Panel", -1, "KIT_Global__Options");
service.SaveAndPublishWithStatus(controlPanel);
// once saved/published, check that it has an ID...
if (controlPanel.HasIdentity)
{
// ... then create the Site Settings node
MakeSiteSettings(controlPanel);
}
}
catch (Exception ex)
{
LogHelper.Error<CreateKitExtensions>("MakeControlPanel", ex);
}
}
private static void MakeSiteSettings(IEntity node)
{
try
{
var service = ApplicationContext.Current.Services.ContentService;
var siteSettings = service.CreateContent("Site Settings", node.Id, "KIT_Global__SiteSettings");
service.SaveAndPublishWithStatus(siteSettings);
}
catch (Exception ex)
{
LogHelper.Error<CreateKitExtensions>("MakeSiteSettings", ex);
}
}
}
}
As I resolve these issues I'll post my solutions here for future reference - feel free to ask any questions but we did try to comment the niggly parts!
It seems strange that you are creating a root-level content node from the content saved event. Why not just create the root-level content node from the ApplicationStarted event?
The property sort order thing sounds like a bug. Worth reporting on issues.umbraco.org.
As a workaround, you could create the document type using the API, then create each tab/property on that document type in the order you would prefer.
Same for the template hierarchy (i.e., create programmatically).
No idea what's up with the image cropper error. I see the stack trace mentions the parameter model binding. Would be worth using the Chrome developer tools network tab to inspect exactly the data the request is sending to the server (e.g., maybe something is null).
Thanks again, I'll check issues and see if anyone else has reported similar!
As I said I'm modifying the code solution above to create and set more properties and values, I'll see what I can dig up on setting tabs and the like in the online documentation; any specific pointers you'd like to share? ;-)
I'll also check the dev tools for any errors in the back office, another good tip as I'm still getting to grips with the angular approach in 7!
Issues with creating a Starter Kit - or "Creating and Packing up, Installing ... OH $&"^+!"£! [Updated]
Evening all,
:TL:DR:
Package Creation: On the initial creation of my starter kit certain files cannot be added due to the inherent limitations of the create package process;Thanks @Lee! :-DInstallation: on kit installation property fields are presented out of order from creation; subsequent content nodes and files are missing; templates will not maintain hierarchy [Updated]
Image Cropper is throwing errors on image submission
Long Version
I'm currently building a starter kit and am running into a few issues with different steps that I hope you can help me with?
Package Creation: (solved ▼)
- While I can easily manually create a settings node in the content tree - when I create the package I cannot select that node of course because it's at root level and NOT a child of the Homepage?Installation:
As stated above, there are definite discrepancies happening when the kit creation process happens, properties of document type properties seem to be missing their order or not copied into the kit?
Let me outline the steps I take to reproduce after creating the kit:
(for now) manually add the settings node to the content treecertain files are actually missing from included folders I added in the package processI figured ths one out as while the kit creation process will grab files in a folder specified, JSON files are ignored, as are SVG's; I added them manualy to the included files and all is well!
Image cropper
So, that's about all for now, and I'm happy to answer any questions you might have and show code privately. If you would need to see the starter kit itself please contact me directly.
I do hope I can get these resolved soon as possible since, for those that know me, I don't have any more hair to pull out!
Thanks for reading!
#h5yr!
I don't have an answer for you, but I am interested in whatever answers you get (I too am thinking of building a starter kit soon).
What version of Umbraco are you using (my assumption is the latest... 7.3.1)?
Also, since starter kits are really just a collection of files and a config file, I wonder if you might solve some of your issues by manually modifying the config file. Just a thought.
Also, perhaps it would be a good idea to create some tickets on issues.umbraco.org for each of the specific problems you've noticed. I would be interested in seeing a resolution as soon as possible, and that's one of the better ways of going about it (assuming the issues you are seeing are due to bugs).
@Nicholas,
Thanks for reading the whole post! :-D
In response, and to help others:
If there was a starter kit with a settings node that I could find the source for I would be able to understand the whole process much better...?
Thank you for your time and patience, I'll post any findings that come to light!
Cheers!
Jon
Right!
Thanks to @LeeKelleher I've a solution for the first part of my question above:
Package Creation
Here's the snippet for any and all to use - please note, this will be updated in my instance yet it's the best start I can give back to the community!
As I resolve these issues I'll post my solutions here for future reference - feel free to ask any questions but we did try to comment the niggly parts!
#h5yr
It seems strange that you are creating a root-level content node from the content saved event. Why not just create the root-level content node from the ApplicationStarted event?
Nicholas,
I'm going to, so thanks for the confirmation of right track!
I have other documents types and properties the need created programmatically - the above was a first working prototype - thanks to Lee!
Any thoughts on the other issues:
Cheers for checking back!
#h5yr!
The property sort order thing sounds like a bug. Worth reporting on issues.umbraco.org.
As a workaround, you could create the document type using the API, then create each tab/property on that document type in the order you would prefer.
Same for the template hierarchy (i.e., create programmatically).
No idea what's up with the image cropper error. I see the stack trace mentions the parameter model binding. Would be worth using the Chrome developer tools network tab to inspect exactly the data the request is sending to the server (e.g., maybe something is null).
Nicholas,
Thanks again, I'll check issues and see if anyone else has reported similar!
As I said I'm modifying the code solution above to create and set more properties and values, I'll see what I can dig up on setting tabs and the like in the online documentation; any specific pointers you'd like to share? ;-)
I'll also check the dev tools for any errors in the back office, another good tip as I'm still getting to grips with the angular approach in 7!
Your help is greatly appreciated!
J
is working on a reply...