Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew 2 posts 32 karma points
    Jun 15, 2015 @ 04:02
    Matthew
    0

    Care to share a cup of Doctype/Composition best practices?

    I was studying up on compositions, thinking this new site I'm starting would maybe use them for the majority of properties. Before I get too far along, anyone willing to share their current best practices how they take advantage of compositions in a 'typical' small organization website (with home page, section pages, landing pages, content pages, event listing pages, etc)?

    Or is there a starter kit that really showcases how to use compositions at a comprehensive level, rather than just a rudimentary demo?

    Thanks very much folks, much appreciated.

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jun 15, 2015 @ 15:14
    Tim
    100

    I tend to break it down and have Compositions for specific tabs of re-usable content. So for example, I'll have an SEO composition that contains a tab for all the SEO properties like meta title, keywords, description, OpenGraph/Twitter Card details etc. I'll have another for tracking/conversion scripts that might want to be included on multiple page types.

    Then, for things like content, I'll have a composition with all of the common fields on, and then add any additional content tab fields on each DocType.

    Basically, if it's a set of fields that you might use on multiple page types, use a composition for that part of the DocType. I use it in a similar way to the older DocType Mixins package (although Compositions work slightly differently).

    One other bit of advice, Compositions can only be stored in the root of your DocTypes, so prefix them with something to avoid confusion and make them easier to find.

  • Matthew 2 posts 32 karma points
    Jun 15, 2015 @ 22:02
    Matthew
    0

    Thanks Tim, that's helpful. I had been thinking about them backwards, using them to add special functions, rather than for common/reusable ones and putting the special functions on the specific doctypes. Makes much more sense your way.

    Appreciate the mention on the prefix too, I'd seen that but hadn't really thought about the confusion after things get built out a ways.

    Thanks again.

Please Sign in or register to post replies

Write your reply to:

Draft