2

Consider a site with a very flat hierarchy that has a lot of basic pages. Most pages on the site are extremely similar, so they can all share the same entry type (and thus, fields) without problems.

The problem is, there are a few pages that have wildly unique content layouts. There's special content that will only ever be used on these pages.

From my understanding, there's a few solutions to this:

  • Use a Matrix field in the Page entry type and add a block for each special page you need. This lets you build the unique pages, but for the dozens of other "normal" pages it becomes very weird and unnatural (plus there's nothing stopping the client from erroneously adding the 'special page' Matrix blocks on non special pages).
  • Using multiple entry types, but this is also a bit clunky and would mean have to using a Channel or Structure.
  • Use Global sets (one for each special page). Also a bit of a dirty workaround.

Is there a cleaner way to achieve "one-off" fields that are used only by a specific entry?

Another CMS - Bolt - has a solid solution to this: Template Specific Fields. As another example: using WordPress with ACF, you can assign field layouts on a per-entry basis if required.

I was hoping something similar could be achieved in Craft.

1
  • 1
    Maybe this plugin could support you as well: github.com/mmikkel/Reasons-Craft This hides or shows fields based on a lightswitch. This could be practical to further increase usability in your case.
    – KSPR
    Jun 29, 2016 at 6:24

1 Answer 1

3

Let's start by saying what you don't want to do...

  • Don't use Matrix blocks to solve this problem. As you mentioned, the Matrix field would get pretty crazy, and you couldn't prevent people from using the wrong blocks in the wrong places.
  • Don't use Globals to solve this problem. Global fields get loaded automatically on every page load, so you're bound to add a lot of extra page weight that doesn't need to be there.

To me, it sounds like entry types are the perfect solution. You can have multiple entry types which all share the same fields, but then add extra fields to the entry types which specifically need them. If I'm understanding your problem correctly, it's exactly what entry types were created to solve.

Lastly, you mention needing a Channel or Structure to use entry types. This is 100% true, but it makes me wonder... Are you currently just using Singles? If you're currently using Singles, then this should be a non-issue... each Single is basically a unique entry type anyway.

Hope that helps, let me know if I missed something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.