Overview

Drupal CMS currently has two content templates in its site template -- both of them need to use adapted prop sources (XB's own unix_to_date, in one; a custom one, to link to entities, in another). Both are absolutely necessary:

  • In blog posts, we need to show the date the post was created. That is pulled from the node's created field, naturally. The raw value is a timestamp, but it's being injected into an SDC prop that has type: string and expects the YYYY-MM-DD format: https://git.drupalcode.org/project/mercury/-/blob/1.x/components/hero-bl.... It reformats that in the Twig template (see https://git.drupalcode.org/project/mercury/-/blob/1.x/components/hero-bl...). Right now, the only way to convert the value from a timestamp to the expected format seems to be to use XB's unix_to_date adapter. I'm not sure what other option we have, but I'm certainly open to doing something different (even if means changing the theme; maybe we change the component to accept a timestamp?).
  • Drupal CMS's site template has a view of blog posts. The posts are displayed as a grid of cards, using this component: https://git.drupalcode.org/project/mercury/-/tree/1.x/components/card?re.... The component has a URL prop (also type: string). How can we get the URI of the blog post being displayed ($node->toUrl()) into that prop? There is no field for this that I'm aware of. I suppose the closest thing we could do is directly introspect the path field's alias property, although that's not future-proof if a node doesn't have a path at all, but that would possibly an acceptable compromise. But at the moment, the way I got around this is to write a custom adapter which provides the entity URL. Update 9/12/2025: I managed to work around this by creating a computed url field on nodes, which returns the value of $node->toUrl()->toString(). Kludgey but it'll do for now.

There is, however, a validation constraint on content templates which rejects any adapted prop sources found in the component tree. This restriction no longer makes sense given Drupal CMS's needs and should be lifted.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phenaproxima created an issue. See original summary.

wim leers’s picture

Component: … to be triaged » Config management
Assigned: Unassigned » phenaproxima
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update
Related issues: +#3541000: [META] Content templates UI for 1.0: only nodes, no exposed slots, no replacement for the view mode/display UI, +#3536115: Allow use of same-shape-adapters ahead of general adapter support in #3464003

Concerns

This restriction no longer makes sense given Drupal CMS's needs and should be lifted.

It's not that simple.

We're actively working on bringing the MVP for end-to-end ContentTemplate functionality to 1.0 in ~1 month: see the plan at #3541000: [META] Content templates UI for 1.0: only nodes, no exposed slots, no replacement for the view mode/display UI.

That means any ContentTemplate that Drupal CMS would manually craft (that includes adapted prop sources) SHOULD be viewable/editable in that UI.

However, no designs and no implementation work exists at all nor is scheduled to update the UI (JS) nor the ComponentInstanceform to support adapted prop sources.

tl;dr: what you're asking (demanding, almost 😅) would result in a crashing UI.

Suggested next steps

  1. Please update the issue summary with information about why those 2 adapted prop sources are "absolutely necessary". That will help frame the conversation and keep the scope reigned in 🙏
  2. I was hoping to get minimal support for adapted prop sources going, in #3536115: Allow use of same-shape-adapters ahead of general adapter support in #3464003, but other things have been taking priority. If you could push that forward, we might be able to achieve what you need without the above negative consequences.
phenaproxima’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Updated!

phenaproxima’s picture

Issue summary: View changes
lauriii’s picture

Could we please split this to two separate issues? I'm not sure that adapted prop sources is what's needed here. You should be able to map date field to a format: date string. If that's not the case, that's a bug on it's own.

phenaproxima’s picture

Issue summary: View changes
lauriii’s picture

Project: Experience Builder » Drupal Canvas
wim leers’s picture

@lauriii in #6: But the created field on Nodes doesn't uses a "date" field:

$fields['created'] = BaseFieldDefinition::create('created')

which uses class CreatedItem extends TimestampItem aka a UNIX timestamp. type: string, format: date doesn't accept UNIX timestamps. That's why @phenaproxima was using \Drupal\canvas\Plugin\Adapter\UnixTimestampToDateAdapter, which literally provides that conversion.

The only way around that is Canvas adding a new computed property onto the created field type: that'd elegantly work around this 👍

(Which is what Canvas is doing in a multitude of places, and which @phenaproxima has cleerly started doing too: see #7 and #3545859-2: Add a `host-entity-url` prop source for linking to the host entity.)

phenaproxima’s picture

I'm going to do this in Mercury with a less invasive (no need to mess with field types) approach specific to that one component: https://www.drupal.org/project/mercury/issues/3547303

wim leers’s picture

wim leers’s picture

Between #3547303 and #3545859: Add a `host-entity-url` prop source for linking to the host entity … does that mean the "critical" tag can be removed, and … this issue can actually be closed?

phenaproxima’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
Issue tags: -Drupal CMS dependency critical

Yes, and done!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.