0

My site has a set of different layout types with their own templates:

  • Brochure
  • Listing
  • Plain Text

And the site has a group of hierarchical pages that each use a different layout:

  • About (Brochure Layout)
    • Employees (Listing Layout)
    • History (Plain Text Layout)

So I've got these 3 pages each with different content and layout requirements that all need to be grouped together under the "About" page. But I can only use one Section type per Structure.

I don't want to use Entry Types, because I need to use the layouts in multiple places on the site. For example there's a Brochure-type page in the site's 'Careers' area. If something about the layout changes I don't want to have to go through multiple Entry Types to make the changes over and over.

  • 1
    The best & easiest solution, IMO, would be to make it possible to save Entry Types for re-use in different Sections. That way you only have to edit one Entry Type if a layout pattern changes. – kmgdev Dec 9 '15 at 22:24
  • Just found this feature request, and Brandon makes a good point about problems raised when tweaking on a per-section basis. Ultimately I think the Structures model is too restrictive and needs to be re-evaluated. Rather than a Section type, the Entries area should be reworked with a separate Navigation model. As an example, I think the way the Structure module for ExpressionEngine handles page hierarchy is very flexible and user-friendly. – kmgdev Dec 9 '15 at 22:47
  • This doesn't directly answer your question, but, I believe, you might be able to partially work around the limitation you're bumping into with some schmancy twig / template organization. Give this presentation a look: speakerdeck.com/acolangelo/template-organization-in-craft – Brett Burwell Dec 9 '15 at 22:49
3

First, try to separate the concepts of content modeling (how things are set up in the CP) and information architecture (how things are going to be presented to the user on the front-end site) in your mind. Are these “Employees” and “History” pages inherently sub-content of “About”, or is that just how you’re choosing to display it on the front-end? My hunch is it’s the latter, in which case a Structure section is not the right choice to begin with - and perhaps 3 separate Single sections makes more sense.

I don't want to use Entry Types, because I need to use the layouts in multiple places on the site. For example there's a Brochure-type page in the site's 'Careers' area. If something about the layout changes I don't want to have to go through multiple Entry Types to make the changes over and over.

I feel you on the annoyance for having to maintain multiple (near-)identical field layouts, and this is something we hope to make better someday, but I would argue that it’s not going to be as bad in practice to keep these field groups in sync as you’re fearing – or at least not bad enough that the currently-possible workarounds will be worth the effort.

  • Fair point, and you're right, I was thinking of Structures as an IA solution and not a content model solution. I assumed that the Structure type was Craft's navigation solution, but it looks like Craft doesn't yet have a comprehensive navigation model. – kmgdev Dec 9 '15 at 23:07
  • @kgrote Right. There are one or two plugins that help with navigation, but currently Craft doesn’t have any built-in IA modeling features. – Brandon Kelly Dec 9 '15 at 23:09
  • Browsing the StackEx boards, it does seem like I'm not the only one who had that assumption, especially with the {% nav %} tag being associated with Structure-type entries. I think people are seeing the word "nav" and assuming that's Craft's navigation model and it's somehow tied to Structures. – kmgdev Dec 9 '15 at 23:37
  • 1
    @kgrote there's many Craft users that use a structure named "Pages" with different Entry Types instead of singles. I think it's a great starting point for the site nav and as Entry Types are reusable you don't have to set up a Field Layout, paths and everything for every single page. – carlcs Dec 10 '15 at 0:43
  • @kgrote I think this feature would make editing field layouts a lot better: feedback.buildwithcraft.com/forums/285221-feature-requests/… ! Update the field group and just drag it into each Entry Type you use it unmodified to update its fields. – carlcs Dec 10 '15 at 0:57
2

If something about the layout changes I don't want to have to go through multiple Entry Types to make the changes over and over.

Suspend judgement about whatever you think you know about Entry Types for a minute.

Unlike other CMS like WordPress where a page template typically defines a layout, Entry Types in Craft are a lot more flexible (because you can also use a different set of custom fields for each type).

More importantly, in your case, there's no relationship between the template you might use for that particular entry type, unless you want there to be. Twig is awesome in helping to ensure your code is DRY.

You can absolutely reuse Entry Types in different sections. There's nothing stopping you setting up an Entry Type in one section and using the same name in another. It's up to your on what template you want to load; in that case, just borrow the same Twig code.

  • What if my content structure changes and I need to add a field? I'd have to go into every single Entry Type for every unique Structure section and manually add the field over and over again. What's DRY about that? – kmgdev Dec 9 '15 at 22:54
  • 1
    See Brandon's answer to answer your question. I feel your pain on duping fields but in general if you find yourself having to keep remodeling your content structure, you probably have IA issues to begin with. Entry Types and Sections are like rooms in a house, they should have a specific purpose. If you want to keep duplicating the same lamp in every room, that's going to be a pain no matter how you slice it. – RitterKnight Dec 9 '15 at 22:59
  • "if you find yourself having to keep remodeling your content structure, you probably have IA issues to begin with" - Have you ever met your average client? 😜Don't know about you, but I've had to add a field many times when a marketing department decides they want to add google tracking code or tags to entries. – kmgdev Dec 9 '15 at 23:16
  • Yup, plenty of clients. I think you're making a mountain out of a molehill here. – RitterKnight Dec 9 '15 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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