1

So, I'm building a portfolio site for a client, and I'd like to know if it's possible to hide fields on a parent entry. Essentially, I've created a structure for portfolio items, and they are all children of the main "Works" page. I've built a set of fields for each portfolio item, but I don't want those fields to show up on the parent entry, as they are unnecessary and therefore distracting. Is there a way I can do this?

Thanks in advance!

3

You can create two different Entry Types for your Structure section, and use one Entry Type for parent entries, and a different entry type for child entries. Entry Types have their own field layout, which makes it possible to have different fields for different kinds of entries, within the same Section. Then, it's simply a matter of selecting the right Entry Type when you create/edit your entries.

If that isn't dynamic enough (it isn't possible to assign entry types automatically based on whether an entry has children or not), you could possibly use the CP CSS plugin (perhaps in combination with the CP JS plugin) to hide the relevant fields for the parent entries.

I realize that neither of these solutionals are ideal – however, if you only have a single parent (i.e. "Works") for all your portfolio entries, I think a better approach would be to create a separate "Portfolio" Structure section limited to a single level, to hold all your portfolio entries. Set the URL format for this section to "works/{slug}". Under /templates/works you can add two templates, index.html and _entry.html. The former will render for the URL example.com/works and can be used for your portfolio section's listing page (i.e. it'd replace the current "Works" parent page), and the latter template's path (i.e. works/_entry) should be added to your portfolio section's Entry Template setting.

If you do need some fields for the listing page, you could create a Single called "Works" and set its URL Format and Entry Template path to just "works". A setup like this would circumvent your issue completely (and also avoid the problem with content editors getting your current solution wrong; adding new portfolio entries to the top level).

2

Or in Addition to Mats answer you could use the reasons plugin to hide and show fields based on a lightswitch button. But when you have lots of different fields, different entry types are the way to go.

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.