Right now you cannot make linkit links in a way that will always ensures content can be found that is being linked to. A managed link will look like <a data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="d1daaf44-db1e-4951-906a-df036ef2e3c5" href="/node/43">About Cancer</a>. The problem with just pasting in this link is that when we load the content the UUID and href can change. Other content being loaded can change node ids. Also looking through the generator function it looks like it is based on random elements like the time, etc. So the node being created each drupal install will generate a new UUID.
We can look towards the logic for handling <drupal-entity> references in YAML content with a way to query the system for the node that was created.
LEAVE OUT HREF - this will get filled in once the entity is found and the route to the entity should be used.
data-entity-uuid="#process" - This tells us to process this entity and expect that we should be able to find all the other required attributes.
data-entity-type - This is actually a drupal-entity attribute, but it is the entity type that is being embedded and is important for looking up the entity.
data-cgov-yaml-query-* - Additional parameters for the query, this should match the various queries done elsewhere in YAML content reference fields. (as referenced in the Technical Notes above. Examples would be:
Node
data-cgov-yaml-query-type - the bundle name
data-cgov-yaml-query-title - The node title
Media
data-cgov-yaml-query-bundle - the bundle name
data-cgov-yaml-query-name - the media items name
This would get done in docroot/profiles/custom/cgov_site/modules/custom/cgov_yaml_content/src/Service/YamlEntityEmbedProcessor.php next to the code that handles <drupal-entity>.
Notes
Ticket for handling Embedded Entities in yaml content- #2762
Right now you cannot make linkit links in a way that will always ensures content can be found that is being linked to. A managed link will look like
<a data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="d1daaf44-db1e-4951-906a-df036ef2e3c5" href="/node/43">About Cancer</a>
. The problem with just pasting in this link is that when we load the content the UUID and href can change. Other content being loaded can change node ids. Also looking through the generator function it looks like it is based on random elements like the time, etc. So the node being created each drupal install will generate a new UUID.We can look towards the logic for handling
<drupal-entity>
references in YAML content with a way to query the system for the node that was created.Where the following parameters are:
data-entity-uuid="#process"
- This tells us to process this entity and expect that we should be able to find all the other required attributes.data-entity-type
- This is actually a drupal-entity attribute, but it is the entity type that is being embedded and is important for looking up the entity.data-cgov-yaml-query-type
- the bundle namedata-cgov-yaml-query-title
- The node titledata-cgov-yaml-query-bundle
- the bundle namedata-cgov-yaml-query-name
- the media items nameThis would get done in
docroot/profiles/custom/cgov_site/modules/custom/cgov_yaml_content/src/Service/YamlEntityEmbedProcessor.php
next to the code that handles<drupal-entity>
.Notes