Comments (21)
Can you elaborate a bit Mike, what would you be most interested in? I suppose just adding an example with such a content type being created from migrations wouldn't help much.
from orchard-training-demo-module.
Yes! I have an OC site which is a decoupled CMS. All content types/items have been created via the admin UI. Using your (amazing) training module I'm trying to convert all content types to C#, creating custom editors, etc. I have a content type which has a few taxonomy fields. What I would like to know how to do is how to create taxonomies and reference them in C# like this:
The Tags
taxonomy in the screen shot uses the new "tags" functionality while the Branching Strategy
is just a standard taxonomy.
from orchard-training-demo-module.
In the O1 version of our Helpful Extensions module, we have a content type code generation feature. Wouldn't this be something you're looking for?
from orchard-training-demo-module.
That does sound very interesting! At this point, though I'm more interested in the knowledge than an automation step. Although I suppose seeing the output of that would provide a lot of knowledge.
from orchard-training-demo-module.
Oh I see now. So that's how I would add the field. I would then use a recipe to create the custom taxonomy and associate it with the content type?
from orchard-training-demo-module.
That would be one way, yes. There's not much unique in adding a specific field apart from its own settings. If we have code generation then that can be much easier. Then adding the Taxonomy itself can happen just with recipes as that's a lot more data usually than what you want to keep in C# (but if it's just a 5-term Taxonomy you also could very well add the terms from code, with IContentManager
.
from orchard-training-demo-module.
I've implemented the migration code generation feature in this branch (I wanted to do it for a while anyway): Lombiq/Helpful-Extensions#5 Could you please check it out if it helps you?
from orchard-training-demo-module.
Oh this looks great! How do I run it? Add a nuget package reference and hit a url?
from orchard-training-demo-module.
Not yet since it's just in a branch. I'll work on it a bit some more, so, for now, checkout its branch from the repo and add it as source to your solution just as your own modules. Here's how to use it: https://github.com/Lombiq/Helpful-Extensions/pull/5/files#diff-1e290ac8433d555bce009b162cb869d0
from orchard-training-demo-module.
I gave it a try but am getting an exception:
System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JValue'.
at Lombiq.HelpfulExtensions.Extensions.CodeGeneration.CodeGenerationDisplayDriver.<Edit>g__AddSettingsWithout|0_2[T](JObject settings, Int32 indentationDepth, <>c__DisplayClass0_1& ) in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Extensions\CodeGeneration\CodeGenerationDisplayDriver.cs:line 38
at Lombiq.HelpfulExtensions.Extensions.CodeGeneration.CodeGenerationDisplayDriver.<>c__DisplayClass0_0.<Edit>b__1() in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Extensions\CodeGeneration\CodeGenerationDisplayDriver.cs:line 101
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Lombiq.HelpfulExtensions.Extensions.CodeGeneration.ContentTypeMigrationsViewModel.get_MigrationCode() in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Extensions\CodeGeneration\ContentTypeMigrationsViewModel.cs:line 8
at AspNetCore._Areas_Lombiq_HelpfulExtensions_Views_ContentTypeMigrations_Edit.ExecuteAsync() in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Views\ContentTypeMigrations.Edit.cshtml:line 12
Let me know if I can provide any further information or if you'd like me to try anything else.
I enabled the module/feature and went to edit one of my content types.
Note that it does work for some other content types. I think it's failing on ListPart.
from orchard-training-demo-module.
Indeed, that was a bug with arrays in part settings, thank you for finding it! I've pushed a fix, could you check it out?
from orchard-training-demo-module.
Woot making progress! That type is fixed but I found another bug:
I'm not sure but I think it might be due to the content type having a text field which has a default value of N/A:
{
"FieldName": "TextField",
"Name": "NotificationGroup",
"Settings": {
"ContentPartFieldSettings": {
"DisplayName": "Notification Group",
"Editor": "PredefinedList",
"Position": "2"
},
"TextFieldSettings": {
"Hint": "The notification group assigned in the availability test alert"
},
"TextFieldPredefinedListEditorSettings": {
"Options": [{
"name": "N/A",
"value": ""
}, {
"name": "Monitoring Readers",
"value": "MonitoringReaders"
}],
"Editor": 1
}
}
}
I could be wrong about that though.
from orchard-training-demo-module.
That was something I thought nobody will ever need :D.
This indeed happens because of TextFieldPredefinedListEditorSettings
. Unfortunately, the JToken containing the Options array doesn't contain any information about the type of items in it (which is ListValueOption). So it's not possible to figure out (in a generic way) how what to instantiate, and thus I don't think we can generate the proper code for it.
So I've opted with something that would still generate the rest of the code but let you know it can't do anything here:
It's a bit meh but I don't see a better way. The information we need is simply not there. And I don't want to cheat by tying the code to TextFieldPredefinedListEditorSettings
and other such settings that need specific support (and their property names are also wrong in the JObject).
Code's in the branch if you'd like to check it out.
from orchard-training-demo-module.
Oh hmm that's interesting. How are the property names wrong in the JObject?
Anyhow I think that is definitely reasonable! I'll pull down the update in the morning and give it a try. This is gonna save me a lot of time and be very educational!
from orchard-training-demo-module.
Woohoo this is phenomenal! It brings up so many new things that I need to learn. IE. how to create these content types with a setting for a TaxonomyContentItemId
.WithField("NotificationGroupRecipients", field => field
.OfType("TaxonomyField")
.WithDisplayName("Notification Group Recipients")
.WithPosition("3")
.WithSettings(new TaxonomyFieldSettings
{
TaxonomyContentItemId = "4k0acdf1frk1432kpjby4z3f5j"
})
)
I need to make more progress through the training demo! Thanks a ton for doing this. It also gives me a bunch of ideas for other parts of the CMS such as generating the file name and path where you can overwrite templates:
Anyhow thanks again!
from orchard-training-demo-module.
What I mean by property names being wrong is that the property names indicated in the JObject ("name" and "value") are not the actual names of the properties of the C# class. Rather, these are just specified for the JSON so I think it's impossible to figure out the property name from them (I mean in a generic way since these names can be overridden by anything).
Anyway, glad you like it! Any other suggestions for the feature?
from orchard-training-demo-module.
Ah I see. That makes sense.
Along with the file name and file path for overriding templates, the same thing could definitely be done for Drivers! Even if it just spits out a shell that could be helpful. i could see the case being made for just using snippets but i would argue that both would be valuable.
from orchard-training-demo-module.
Do you know the Orchard 1 Shape Tracing feature? It's like Chrome DevTools, you point to an element and it shows you which shape drives it, and you can create overrides with all alternates right away. I think something like that would be the best for template generation.
For drivers I think snippets are a more suitable approach. We have such for O1 in the Dojo Library which we'll eventually upgrade for OC.
from orchard-training-demo-module.
I created an issue for your template idea here: Lombiq/Helpful-Extensions#6
from orchard-training-demo-module.
Nice! Thanks so much. If you agree, I think I'll close this issue. Thanks for all the help.
from orchard-training-demo-module.
With pleasure!
from orchard-training-demo-module.
Related Issues (20)
- build:scripts randomly failing (OSOE-559) HOT 8
- Compiling error trying to follow the "Orchard-Training-Demo-Module" (OSOE-778) HOT 12
- Clarification needed on learning path repository to use, "Open-Source-Orchard-Core-Extensions" or "Orchard-Training-Demo-Module"? (OSOE-783) HOT 5
- Error when I try to "Configure" a new Orchard OSOCE Web App with Sql Server in localhost (OSOE-788) HOT 6
- Simplify Lombiq.TrainingDemo and make it available as a standalone solution too (OSOE-797) HOT 15
- Discussion about a guide to getting started (OSOE-798) HOT 2
- InvalidOperationException: The partial view '/Areas/Lombiq.TrainingDemo/Views/InjectedShape.cshtml' was not found (OSOE-806) HOT 6
- path Error HOT 7
- Vuejs Demo not work , and the main.js never used HOT 10
- Workflows activity sample (OSOE-342)
- Suggestion: Possible to add multilingual using Content Localization? HOT 4
- Get build error after install this module and VueJs module HOT 4
- Outdated warning? HOT 1
- OlderThan30 throwing an exception HOT 2
- RC2+ upgrade HOT 1
- INotifier in a theme HOT 3
- TemplateContext.GlobalMemberAccessStrategy is undefined HOT 5
- Lombiq.vuejs Module - compile error in MacOS - Big Sur HOT 4
- Step-by-step setup for training demo module HOT 6
- How to use DisplayDriver when using widgets/flow editor HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orchard-training-demo-module.