Published on September 28, 2014 by Jan Haderka
It’s been a while since I’ve featured a more technically focused post on this blog, so I’ll try to remedy this today.
One of the things that became obvious fairly quickly when we released Magnolia 5 in summer 2013 was that most users, when creating custom apps, create so called Content Apps. In other words, and not so surprisingly, people still use Magnolia as a content management system. This is good, and it’s what we predicted would happen. That’s why we made it very easy to build such apps in Magnolia.
What is a content app?
Before we go into my post, let me quote our documentation to give those of you who don’t know what a content app is a chance to catch up
“Content app is a specialized app type that manages custom data sets. The content app provides a user interface that consists of a browser subapp and a detail subapp. Content apps make it easy to organize items such as contacts or products. Many native Magnolia 5 apps such as Pages and Contacts are content apps. Because this app style is used often, the framework provides convenience classes to make building a content app faster.”
And, if you’ve never done it, here’s a tutorial to create your first app.
On beginners’ mistakes
Nearly in all of my demos, I would show some kind of content app, sometimes even creating it on the fly. In workshops, developers would often write their first content app right then and there.
While you can certainly build the app fast and easily, and while it’s cool that you can configure all UI elements quickly, there are some pains involved - or, to put it differently - it’s easy to make mistakes (like creating subnodes at wrong levels, or with incorrect node types or making typos in names) when configuring the app. Consequently, multiple people have expressed plans to write an App would allow you to create new Apps by simply filling in a form, or by going through some kind of wizard asking you what to do. I’m still hopeful that one day there will be such an App (hint, hint - community members!)
Simplifying the App building process
While I’m waiting for that beautiful App to be created, I’ll give you my intermediate solution to the issue (yep, I’m the kind of guy who still likes to write code in VI or similar kinds of IDEs). So what you get below is not a nice App, but instead a few hundred lines of groovy script that will create an App for you. If you lack imagination like me, you can just specify the display name for your app and let the script derive all the rest. If you are bit more decisive, you can force it to use certain other names for workspace, item name, node type, etc. And if you really want to make yourself heard, you can rewrite all the labels, add extra actions or remove existing ones … just like if you were reconfiguring an app via Admin Central (which of course you can still do).
To prove how easy it is to use, it took me all of 30 seconds to create the following bunch of apps and yes, they all work well enough.
The only thing I ask of you is this - if you find a bug in the script or if you improve it in any way, please contribute the code back so everyone can benefit from it. And without further delays:
A few words of warning
Just like everything else, though, even this script is not without caveats. For it to work properly, you need the following two improvements installed locally.
If you can’t or don’t want to apply patches for issues above, but still want to run the script right now:
Jan is Magnolia's Chief Technology Officer. He has been developing software since 1995. On this blog, he'll write about Magnolia's connectors, integrations and coding ...with the odd Magnolia usability and development tip thrown in for good measure. He lives in the Czech Republic with his wife and three children. Follow him on Twitter @rah003.
See all posts on Jan Haderka