1

I'm struggling to find a solution for a clients request to be given complete flexibility to create new sections and pages from within Craft. Essentially I would create a series of generic page templates which the admin could then use to build out the site and I can use the Navee plugin to provide a way to create a custom navigation. But this does not change the URL of the entry of course. I suppose what I need is a version of the ExpressionEngine Pages module for Craft. Is there such a thing?

  • Not sure if I understood you correctly but it sounds just like you want to create twig templates like every other developer does. That's the normal purpose for Craft. You can then create a macro that goes through your field layout and render different fields how you like it. Please correct me if I understood it wrong but that's just normal twig templating, you don't need any plugins for that – Robin Schambach Jan 12 '18 at 16:50
  • I need a way to create custom URLs, not use the ones set by the URL format field in the section settings. Maybe I'm coming from this the wrong way as I'm used to using ExpressionEngine. – Andrew Jan 12 '18 at 17:11
  • I don't know EE but you can define custom routes in Craft in a config file and of course in a plugin as well. Do you want to create a "single pager" or why don't you want to use the routes in the entry types? Which routes are you going to use? Your question is not really precise about what you want to achieve. You know you have the full power of twig in the url field? So you can create them really dynamic. These URLs defined in the cp are actually "custom". It sounds a little bit like you don't know the power of craft – Robin Schambach Jan 12 '18 at 17:21
  • I think you would get better understanding if you were familar with EE. – Andrew Jan 12 '18 at 19:49
3

There are a few different ways to do this but first I'd recommend stepping away from the idea of doing it like EE. Craft has a lot of flexibility in how the content model can be implemented.

In Craft, if you want a Pages channel with custom slugs, the simplest way is to:

  1. Create a new Section called Pages
  2. Set the Entry URL Format value to {slug}

By setting the URL Format to just {slug} you now have the freedom to create any URLs you want in that section.

The next questions to ask are:

How many variations will I have in the page layouts for these generic pages?

To manage variations you can create multiple Entry Types within a Section. This will allow you to have a one-column page and a two-column page, or whatever variations you need.

But be careful as you add Entry Types. If you have a layout that will only be used once, you may want to consider making that entry a Single or Global or handling it in some other way. I find, that if you add more than 4 or 5 Entry Types it can get very confusing for users as to what they match up to in the templates. Make sure your Entry Types have clear concepts they map to and if you start getting too many, consider your alternatives or how to break up your single Pages channel into multiple, more focused channels.

How do I want to manage these pages in the navigation?

While you can use a Structure Section in Craft to both manage pages and navigation around those pages, be careful how far you take this. Craft uses infinite scrolling in the CP so long structure sections are hard to manage in a way that you can see the structure without just searching for what you want to find. Additionally, often parts of the structure can be delegated to other Channels and you'll be right back where you started with needing to find a way to manage navigation across multiple Sections of content.

Using a plugin like Navee or even a separate Structure Section called 'Navigation' for Navigation has its benefits. When a Structure section doubles as navigation, any change to a slug can change multiple page URLs of children entries and create a need to also manage those updates in SEO and redirects.

By separating the content from the navigation users can update content without breaking navigation or changing URLs. This also gives clients more room to change their mind about how navigation works (as they often do) while putting less pressure on a developer for the need to re-architect several things when those changes happen.

| improve this answer | |
  • Just my thoughts about the entry type that is only used once. Our customers were confused when we separated pages from the structured section if they were only used once (eg imprints or some special pages) that's why we started to restrict those special entry type cases to a certain number (mostly is only one allowed). If the limit is reached users will be unable to create another entry of that type because they'll dissappear from the dropdown. The feedback we received was much better this way and it's much clearer because there will be less in the dropdown – Robin Schambach Jan 12 '18 at 20:14
  • Interesting. So you have a custom plugin that hides an Entry Type after it is used a certain number of times? How do you manage the templates at the code level? If another developer inherited a Craft site with 10 hidden, one-off, entry types, how would they begin to make sense of what templates those entry types are managed by? – Ben Parizek Jan 12 '18 at 23:26
  • Yeah we included an array in our config.php with typeHandle => limit and when the limit is reached the entry type is removed from the list in the cp, when you remove/delete an entry with the specified type it appears again. This is managed by our default plugin that is installed in every project and has much more of these features (like per site plugin settings) so everyone in our company knows about that. I'm not sure what you mean with "what templates they are managed by"? There is a Craft hook cp.entries.edit where you can restrict the entry types. – Robin Schambach Jan 12 '18 at 23:43
  • Just to avoid confusions. They don't disappear in the "admin" section list. They only disappear in the entry form. Sorry about the confusion (as you can probably see my english is not so good) we only remove the entries from the dropdown where our customers can choose the type not in "our" admin -> sections -> entry types view where you manage the field layout and such – Robin Schambach Jan 13 '18 at 0:18
3

A common approach is to create a Structure for the pages, and use a Content Builder where you can use Matrix blocks of various types to allow the client to build out the pages as they see fit in the Structure.

| improve this answer | |
  • So far the best approach to achieve this that I can see is to create a Structure section with multiple entry types for different types of page. This will allow the content admin to give each entry a unique URL. Then the Navee plugin can be used to organise the entries into seperate sections if needed. This seems a bit of a hack to me, (compared to EE), but if that's the way it needs to work so be it. – Andrew Jan 12 '18 at 19:48
  • While there are cases where allowing clients to create their own pages is what you want, I think in most cases it's not ideal. When you do need it, if you take the Matrix content builder approach, you won't need different entry types for each "page type". And you will end up with something much more powerful than was possible in EE. – andrew.welch Jan 12 '18 at 22:25
  • Agreed, Ben Parizek makes a similar point above. – Andrew Jan 13 '18 at 9:53

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.