Open tisto opened 3 years ago
This would be the perfect thing for an adapter.
My proposal, rather then hardcoding this implementation into the actual components (Navigation, Breadcrumbs, etc), let's do this more "adapter-like".
We could have a new section in the "~/config" that is called "adapters". So we coud have the "navigationTitle" concept, where we can register a utility that can extract the navigation title from the content.
const config = {
...,
adapters: {
navigationTitle: (content) => content.title
}
}
Then projects or addons can override this and use content.nav_title, for example. And we should change the Navigation and Breadcrumb component to do navigationTitle(content)
.
@tiberiuichim I'm +1 with this, although the nav_title
seems more core feature than a customisation... but I can imagine other use cases where it makes sense... crap we need an incarnation of ZCA for JS at some point! :P
Is your feature request related to a problem? Please describe.
Page titles are often very long (especially in German). This breaks the layout of the navigation, navigation portlet, breadcrumbs, and grid blocks.
Describe the solution you'd like
Make Volto use a nav_title when this is provided by a content type (e.g. by the kitconcept.volto navtitle behavior: https://github.com/kitconcept/kitconcept.volto/blob/master/src/kitconcept/volto/behaviors/navtitle.py). Gracefully fall back to the regular page title when this field is either not set or not available at all.
Describe alternatives you've considered
We use to override this for every single project we do these days. This is certainly possible. Though, we believe that this is a feature that should belong into core. Overriding trivial core features will lead to a huge maintenance burden over time.
Additional context
The Plone backend is flexible enough to provide different kinds of functionality. We can make this a pattern by treating certain fields/behaviors as an interface (which we need to properly document). If we define certain fields as extension fields (e.g. nav_title, or seo_title (from kitconcept.seo)) any kind of extension can provide those fields and Volto just displays them.
This should of course, only work for fields that we consider to be base functionality. Another option would be to add this functionality to Plone/Volto core in the first place. Though, both nav_title and SEO fields is something that not all sites might need and want.
An alternative would be to provide extension slots and allow flexible override. Though this is a problem that we never properly solved in the Plone community (see viewlets, portlets, etc.) and that includes a significant overhead and complexity.