36 votes

DocTypeMixins

Summary

DocType creation done Ruby style! We have inheritance via nested DocTypes which are great but we still found them a little limiting. What if you have a bunch of properties you want to be on a number of doctypes but some of those DocTypes don't make sense to be under a parent DocType? You could cut and paste the fields over from one DocType to another (and we've all been there) or you could install this package.

How to use

Once installed you will find a new Master Doc Type called "Mixins". This is used to store you new partial DocTypes under, you never actually create a Content Item from these Mixin's. When you create a new Mixin (or edit an existing one) just add any tabs/properties you like for this Mixin. As an example you might want to create an SEO mixin with meta tag fields etc. Save your mixin.

Then create any "real" DocTypes you like but don't bother adding the SEO fields, save it and instead go back to your SEO Mixin and under the Structure tab check all the "Allow child DocTypes" that you want to have you SEO fields added to. Then the magic part, press save.

In the background all the Tabs and Fields will be copied to all the DocTypes you set as Child DocTypes, no more cutting and pasting. Now don't worry, we've built in some sensible defaults. If a tab or property already exists on the target DocType we skip it and leave it be (and give you a heads up in the log). This means you can add standardised fields to lots of DocTypes in one go, no more typos or switching between screens. Even better though is if you want to add another fields to your SEO Mixin you can, and on save, it will be copied over to all the associated DocTypes while leaving the existing properties be. If you delete a property from a Mixin we won't do anything, its not safe for us to do so, so that property will keep existing on any DocTypes that already have it. Simple right.

Its another tool in the box for building the DocTypes you need quickly. Use it along side Inherited DocTypes or instead of, the choice is yours. Unlike the inherited model a DocType can have multiple Mixins, more flexibility!

We wrote up some more tips on using DocTypeMixins on our blog (http://offroadcode.com/blog/2011/9/16/some-tips-on-using-our-umbraco-doctype-mixin-package/).

Let us know how you find it or if you have any questions or queries. 

EXPERIMENTAL!

In version 2 of DocTypeMixins we have introduced the ability to apply mixins simply by dragging and dropping them onto the doc type you wish to apply them to. At this time however this feature is somewhat experimental so to enable this feature you will need to add an app setting to your web.config with the key DocTypeMixins:EnableDragDrop and a value of true. If you spot any issues with the drag and drop feature, removing this setting will allow you to go back to the old way of working without problems.

Upgrading

To upgrade, simply install over the top of any previously installed version.

Yet another of our many best practise tools for helping developers make better websites, check out our other packages including Asset Compressor, XSLTouch and XSLToJson.

Change log

1.1

  • Added checks to prevent mixins from being applies to other mixins
1.2
  • Fixed issue with AddPropertyType erroring

1.3

  • Added icons to more easily identify mixins
  • Removed "umb" property restrictions as it was necessary

2.0

 

  • Now works with Umbraco 6.x
  • Removed un-needed property groups on Mixin doc types
  • Added drag and drop support

 

Screenshots

 Download package
version 2.0

Project owner

Peter Duncanson

Peter Duncanson

Peter has 1220 karma points

Project Compatibility

This project is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
7.5.x (untested)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (100%)
6.1.x (100%)
6.0.x (untested)

You must login before you can report on package compatibility.

Project Information

  • Project owner: Peter Duncanson
  • Created: 08/06/2011
  • Current version 2.0
  • License MIT
  • Downloads: 3411

External resources

Our.umbraco.org is the community mothership for Umbraco, the open source asp.net cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.5.6