Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listing Block template for Page/News Item/Event based on content type. #6055

Closed
wants to merge 6 commits into from

Conversation

iFlameing
Copy link
Member

@iFlameing iFlameing commented May 28, 2024

Still long road to go. Fixes #4765

  1. Added the variation for listing.
  2. Needed thought for migration.

Replicate same things for search.


📚 Documentation preview 📚: https://volto--6055.org.readthedocs.build/

@iFlameing iFlameing marked this pull request as draft May 28, 2024 14:41
Copy link

netlify bot commented May 28, 2024

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit af37944
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/66589245aa93c400085d3dd6

config?.getComponent &&
config.getComponent({ name: 'ListingTemplate', dependencies: [type] })
.component) ||
contentTemplate[type];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iFlameing Using the registry here is good, but I think the way RenderAccordingToContentType is currently implemented, it needs to know too much about the specific listing variations that exist (i.e. the boolean props for image and grid).

Also the contentTemplate mapping should not be hardcoded here. That is what the registry lookup is for.

Instead I would suggest to get rid of RenderAccordingToContentType, and do the registry lookup directly in the variation templates (i.e. in DefaultTemplate, SummaryTemplate, and Grid).

Each variation should use a different component name in the registry lookup:

  • default variation -> ListingTemplate component type
  • summary variation -> ListingWithImageTemplate component type
  • grid variation -> ListingGridTemplate component type

If you have questions about how to use the registry while I am asleep, @sneridagh can probably help.

@davisagli
Copy link
Member

@iFlameing For migration / backwards compatibility, we have 2 options:

  1. Tell users how to run a script to update all existing blocks content with the new names
  2. Add a mapping in the volto settings from old listing variation name to new listing variation name, so that the block can automatically convert old names when it is rendering.

I like option 2 better. It's a lot simpler for users, and still pretty easy to implement.

We'll need a section in the upgrade guide to explain how to configure this mapping if the user wants something other than the default one.

@iFlameing
Copy link
Member Author

@davisagli pleaser review it once again. I will rename the variable once it is done. Same for default content type. I will register it wit config.register component.

@iFlameing iFlameing marked this pull request as ready for review May 30, 2024 13:01
@iFlameing iFlameing requested review from davisagli and sneridagh May 30, 2024 13:02
@tisto
Copy link
Member

tisto commented Sep 6, 2024

@iFlameing this PLIP/PR is mentioned in the Plone roadmap that is about to being published next week. We should try to put some effort into this. Maybe some folks at the Salamina sprints can help. cc @davisagli @sneridagh @fredvd @jackahl

@davisagli
Copy link
Member

We are trying a different solution in Volto Light Theme: kitconcept/volto-light-theme#462 -- that one introduces a Summary component which makes it easier to add a new content type's summary that is used in several different blocks, and also avoids the need to migrate existing block variation names. If it works well then we can consider handling it that way in Volto or Seven in the future.

@davisagli davisagli closed this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Listing/Search Block Variants for Page/News Item/Event/File
3 participants