Skip to content

Conversation

@rbcorrales
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

This PR adds a new block for displaying Collections with customizable layout and filtering options.

Query options:

  • Recent collections with category filtering and offset
  • Specific collections with manual selection via autocomplete

Layout and display options:

  • Grid layout (responsive 2-6 columns)
  • List layout with configurable image alignment (top/left/right)
  • Image sizing for list layout: small, medium, large
  • Toggleable display of all fields, like featured image, title, categories, excerpt, volume/number/period metadata
  • Configurable CTAs with subscription/order toggles and specific CTA filtering
  • Editable "See All" button linking to collections archive

Technical details:

  • Hybrid block with React editor components and PHP server-side rendering
  • Integrates with the existing REST API for the live editor and extends the CTA fields in the JSON response
  • Modular component architecture
  • Integration with existing Query_Helper and Template_Helper classes

ToDo:

  • Currently, the block can also be used in the Collections archive template, as the design should visually match 1:1 (with the appropriate settings), but it will be missing pagination. This would be nice to have to be able to use this block to render the same Collection components everywhere.
  • Unit testing
  • Add the ability to render iframes with the digital editions

Closes NPPD-797.

How to test the changes in this Pull Request:

  1. Ensure the Collections module is active. The block only registers when Collections::is_module_active() returns true.
  2. Create or edit a post/page. Go to the editor and add a new Collections block in the block inserter.
  3. Test default configuration. Verify the block displays 4 collections in a 4-column grid layout with no excerpts, all metadata enabled (volume/number/period), and 1 CTA per collection.
  4. Test Query Settings panel. Switch between "Recent Collections" and "Specific Collections" query types, set the number of collections, adjust the offset for recent collections.
  5. Test category filtering for recent collections. Use the "Include Categories" and "Exclude Categories" autocomplete fields to filter collections by category.
  6. Test specific collections selection - When the query type is "Specific Collections", use the autocomplete field to search and select individual collections by name.
  7. Test Layout Settings panel. Switch between Grid and List layouts, adjust columns for grid (1-6), test image alignment for list (Top/Left/Right).
  8. Test image sizing for list layout. When the layout is List, verify the Image Size control appears with Small/Medium/Large options and affects image dimensions accordingly.
  9. Test Display Settings panel. Toggle each display option: Featured Image, Title, Category, Excerpt, Period, Volume, Number, CTAs and "See All" Link.
  10. Test CTA controls - Adjust "Number of CTAs", toggle "Show Subscription URL" and "Show Order URL", test "Specific CTAs" field with comma-separated CTA labels.
  11. Test the section header. Click the placeholder text at the top of the block to add an editable section header.
  12. Test "See All" button customization - When "Show See All Link" is enabled, edit the button text via the "See All Link Text" field.
  13. Test frontend rendering. Verify the block displays correctly on the frontend with consistent styling and functionality matching the editor preview.
  14. Test responsive behavior. Check that the grid layout responds properly: 2 columns on mobile, 3 on tablet, and respects column setting on desktop (960px+).
  15. Test category links. On the frontend, click category tags to verify they link to collections archive with category filtering (/collections/?category=slug).
  16. Test block example preview. Insert the block and verify it shows the example configuration with "Featured Collections" header and 4 collections in grid layout.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@rbcorrales rbcorrales requested a review from a team as a code owner September 2, 2025 14:04
@thomasguillot thomasguillot added [Status] Needs Review The issue or pull request needs to be reviewed [Status] Needs Design Review labels Sep 4, 2025
@thomasguillot thomasguillot self-requested a review September 4, 2025 09:05
@thomasguillot
Copy link
Contributor

@rbcorrales I pushed a bunch of changes to the block. I have one question... why do we need a sectionHeader? Surely it can be a standalone heading block, or am I missing something?

@rbcorrales
Copy link
Member Author

@rbcorrales I pushed a bunch of changes to the block. I have one question... why do we need a sectionHeader? Surely it can be a standalone heading block, or am I missing something?

Hey @thomasguillot indeed, this could be achieved using a separate block. I just followed the pattern of the Content Loop block for consistency, which also allows you to include a header in the block itself. Do you think it's better to remove it?

@thomasguillot
Copy link
Contributor

@rbcorrales The Content Loop block uses it as a quick way to add section headers so you can stack different sections on a page (that said, I’m not really a fan of having the header baked into this block either).

Anyway... for Collections, I think the use case is a bit different (it's unlikely we're going to stack multiple Collections blocks together) and it probably doesn’t need one.

@rbcorrales
Copy link
Member Author

@thomasguillot done. Header removed with 816599f.

@thomasguillot
Copy link
Contributor

@rbcorrales thank you!

Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

@rbcorrales This is some great and comprehensive work so far! The major functionality is mostly looking good to me. I ran into a handful of minor issues, many of them visual. I'll list in order of descending importance:

  1. The category links aren't working for me. Clicking on a category flag sends me to a URL that looks like this: https://siteurl/collections/?category=collection-category. On my site, which had Jetpack Search enabled, it led to a page that looks like this:
Screenshot 2025-09-09 at 3 25 28 PM

After this I disabled Jetpack Search and refreshed permalinks, but then the links only led me to the main Collections archive page showing all collections, without filtering by category.

  1. The front-end styles for the "See all" buttons don't look right to me. On my site, I have these colors set in Newspack > Settings > Theme and Brand:
Screenshot 2025-09-09 at 3 30 05 PM

In the editor, the button correctly shows with the #3c434a background color and a white text color:

Screenshot 2025-09-09 at 4 14 35 PM

But on the front-end, it renders the text as the same color as the background, making it invisible until I hover:

Screenshot 2025-09-09 at 3 19 55 PM Screenshot 2025-09-09 at 3 31 13 PM

I think it has to do with the anchor tag not inheriting some theme styles for buttons. Some custom CSS may be required to make this more closely match the button.wp-block-button__link styles.

  1. If showing CTA(s) while not showing excerpts, there could be a little bit of whitespace above the first CTA. (This next one is probably an edge case, but if you only show Category + CTAs, the first CTA button ends up overlapping the category flag). Also, if the block is set to display columns, I'd consider making the CTA buttons the full width of the column, what do you think? (cc @thomasguillot)
Screenshot 2025-09-09 at 3 23 55 PM
  1. (non-blocking) I'm not so sure about the "Specific CTAs" UI being a text input field. Aside from being a little strange conceptually, I notice it's very strict in terms of matching the exact label string, such that if I enter "subscribe" it matches/shows a "Subscribe" CTA but not a "Subscribe now" CTA. @thomasguillot do you have any ideas for improving this UI?

  2. (non-blocking) Do we need a text size attribute like we have for Content Loop?

@thomasguillot
Copy link
Contributor

I'd consider making the CTA buttons the full width of the column, what do you think?

Yes, I agree

@thomasguillot
Copy link
Contributor

(non-blocking) I'm not so sure about the "Specific CTAs" UI being a text input field. Aside from being a little strange conceptually, I notice it's very strict in terms of matching the exact label string, such that if I enter "subscribe" it matches/shows a "Subscribe" CTA but not a "Subscribe now" CTA. @thomasguillot do you have any ideas for improving this UI?

I wonder if we could use an Autocomplete Input that allows multiple selection?

@thomasguillot
Copy link
Contributor

(non-blocking) Do we need a text size attribute like we have for Content Loop?

@rbcorrales would it be easy to copy this from the Content Loop? (including the CSS for the text sizes)

@rbcorrales
Copy link
Member Author

rbcorrales commented Sep 11, 2025

Thanks for your review @dkoo!
Some comments:

The category links aren't working for me. Clicking on a category flag sends me to a URL that looks like this: https://siteurl/collections/?category=collection-category. On my site, which had Jetpack Search enabled, it led to a page that looks like this:

This was due to a change in the query string structure from a hotfix precisely for Jetpack Search. In the subsequent PRs, I brought that change in, so it should be working fine.

If showing CTA(s) while not showing excerpts, there could be a little bit of whitespace above the first CTA.

I rewrote a bunch of the styling in the subsequent PRs too 😅
Let me know if this is still an issue.

Also, if the block is set to display columns, I'd consider making the CTA buttons the full width of the column, what do you think?

I agree, if @thomasguillot agrees, but the thing is that I'm also using this block to render the grid on the archive template now (in the other PRs), so that would also affect the rendering of the grid in those other places, and I'm not sure of how it could affect existing customers already using the functionality.

I'm not so sure about the "Specific CTAs" UI being a text input field. Aside from being a little strange conceptually, I notice it's very strict in terms of matching the exact label string, such that if I enter "subscribe" it matches/shows a "Subscribe" CTA but not a "Subscribe now" CTA

It could be, but it would require some extra logic on a custom component, because it's trying to match that against a custom meta that was precisely set loosely with a link and a label, to accommodate all the possible migration scenarios for different customers.

@rbcorrales
Copy link
Member Author

I agree, if @thomasguillot agrees, but the thing is that I'm also using this block to render the grid on the archive template now (in the other PRs), so that would also affect the rendering of the grid in those other places, and I'm not sure of how it could affect existing customers already using the functionality.

Disregard this. I realized it was working like that before and at some point, I probably broke it. I'll make it fill the whole width.

@rbcorrales
Copy link
Member Author

@dkoo the CTA width was fixed on 6d2ef90, part of #4179. Let me know if it works as expected now.

@rbcorrales
Copy link
Member Author

About the "See all" button color, it's rendering correctly in the editor because it's a richtext, instead of a button (I made it editable at some point, but ran into issues when rendering, so it's a leftover).

But what I noticed on the page is that it's only setting the white color when the link is visited:
image

So if you haven't visited it, it will render the text with var(--newspack-theme-color-secondary-against-white) color by default, and it doesn't look like I'm adding custom styles for this button. Is this maybe a theme color issue? cc: @thomasguillot

@thomasguillot
Copy link
Contributor

I’m wondering if the “See all” button really makes sense as part of this block. Right now it’s pretty basic and doesn’t offer much customization. An alternative could be to turn it into its own block (something like a “Collections Archive Button”), with customization options similar to the Button block—style, colors, padding, width, radius, etc.

This would give publishers more flexibility: they could build more complex layouts (for example, a row with a heading + this new button, followed by the Collections block), or even place a “See all issues →” button anywhere on a page.

@rbcorrales
Copy link
Member Author

@thomasguillot I agree, similar to the previous heading field, it probably doesn't make sense to keep the "See all" button bundled into the block. Conceptually, it's more of a call-to-action than part of the content itself, but creating a dedicated "Collections Archive Button" block feels like it might be over-engineering, since the core functionality that would make it different is just a link to the archive. From a pattern perspective, we should usually try to avoid introducing narrowly scoped one-off blocks when the same result can be achieved with an existing, more general component (like the standard button block).

I vote for removing the button altogether. Yay or nay?

@dkoo dkoo added [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Sep 11, 2025
@dkoo
Copy link
Contributor

dkoo commented Sep 11, 2025

creating a dedicated "Collections Archive Button" block feels like it might be over-engineering, since the core functionality that would make it different is just a link to the archive.

I agree with this—it seems to me like this should just be a standard Button block pointing to the Collections archive URL, no?

@rbcorrales
Copy link
Member Author

I agree with this—it seems to me like this should just be a standard Button block pointing to the Collections archive URL, no?
Yes, and it could be even achieved with block composition via patterns in the editor if needed.

I also removed the "See all" link in this commit, on a separate feedback branch that I will use to create a PR soon to address multiple items without further blocking these PRs.

Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

Approving since the feedback is being addressed in the feat/collections-block-feedback branch!

@rbcorrales rbcorrales merged commit 1185157 into trunk Sep 12, 2025
8 of 9 checks passed
@rbcorrales rbcorrales deleted the feat/collections-block branch September 12, 2025 16:15
@github-actions
Copy link

Hey @rbcorrales, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

@rbcorrales rbcorrales added [Status] Approved The pull request has been reviewed and is ready to merge and removed needs-changelog [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator labels Sep 12, 2025
matticbot pushed a commit that referenced this pull request Sep 18, 2025
# [6.19.0-alpha.4](v6.19.0-alpha.3...v6.19.0-alpha.4) (2025-09-18)

### Features

* **collections:** add Collections block ([#4166](#4166)) ([ea0917b](ea0917b))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([ab71461](ab71461))
* **collections:** collections block feedback ([#4185](#4185)) ([2f203c1](2f203c1))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d601445](d601445))
matticbot pushed a commit that referenced this pull request Sep 22, 2025
# [6.19.0](v6.18.3...v6.19.0) (2025-09-22)

### Bug Fixes

* **indesign-export:** remove feature flag ([#4180](#4180)) ([e3c5c7e](e3c5c7e))
* **my-account:** missing variable and template hook priority ([#4150](#4150)) ([9886618](9886618))
* **newspack-ui:** border radius and padding for buttons, modals, and segmented controls ([#4162](#4162)) ([be750ef](be750ef))
* register with empty name fields ([#4175](#4175)) ([7d6680c](7d6680c))

### Features

* **collections:** add Collections block ([#4166](#4166)) ([ea0917b](ea0917b))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([ab71461](ab71461))
* **collections:** collections block feedback ([#4185](#4185)) ([2f203c1](2f203c1))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d601445](d601445))
* **newspack-ui:** add standalone dropdown button; reorganise dropdown box; add generic spacing ([#4169](#4169)) ([863da1e](863da1e))
* **woocommerce:** add custom currency symbol option ([#4155](#4155)) ([8811a7e](8811a7e))
matticbot pushed a commit that referenced this pull request Sep 25, 2025
# [6.20.0-alpha.1](v6.19.0...v6.20.0-alpha.1) (2025-09-25)

### Bug Fixes

* Improve help text for Guest Contributor checkbox ([#4187](#4187)) ([5790f3d](5790f3d))
* newspack-plugin delay ([#4184](#4184)) ([22e8dc2](22e8dc2))
* update download URL for db.php ([#4193](#4193)) ([4d363db](4d363db))

### Features

* **collections:** add Collections block ([#4166](#4166)) ([1185157](1185157))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([07a5545](07a5545))
* **collections:** collections block feedback ([#4185](#4185)) ([0d0210c](0d0210c))
* **collections:** remove feature flag ([#4195](#4195)) ([b1619ef](b1619ef))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d0cbadd](d0cbadd))
* **content-gate:** add countdown block ([#4176](#4176)) ([f8fe757](f8fe757))
* **my-account:** subscription switch modal ([#4177](#4177)) ([28c26e7](28c26e7))
* subscription tier modal ([#4164](#4164)) ([4d6ebe2](4d6ebe2))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.20.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Oct 6, 2025
# [6.20.0](v6.19.0...v6.20.0) (2025-10-06)

### Bug Fixes

* ga4 events for gate interactions and tiered modal ([#4209](#4209)) ([2d35768](2d35768))
* Improve help text for Guest Contributor checkbox ([#4187](#4187)) ([5790f3d](5790f3d))
* newspack-plugin delay ([#4184](#4184)) ([22e8dc2](22e8dc2))
* remove content gate countdown block ([0204e58](0204e58))
* update download URL for db.php ([#4193](#4193)) ([4d363db](4d363db))

### Features

* **collections:** add archive link in settings page ([#4203](#4203)) ([42694ec](42694ec))
* **collections:** add Collections block ([#4166](#4166)) ([1185157](1185157))
* **collections:** add css classes to meta elements ([#4208](#4208)) ([7fbf7e9](7fbf7e9))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([07a5545](07a5545))
* **collections:** collections block feedback ([#4185](#4185)) ([0d0210c](0d0210c))
* **collections:** remove feature flag ([#4195](#4195)) ([b1619ef](b1619ef))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d0cbadd](d0cbadd))
* **content-gate:** add countdown block ([#4176](#4176)) ([f8fe757](f8fe757))
* **my-account:** subscription switch modal ([#4177](#4177)) ([28c26e7](28c26e7))
* subscription tier modal ([#4164](#4164)) ([4d6ebe2](4d6ebe2))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.20.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge [Status] Design Approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants