I have a custom entity, sample. I’ve used the entity display settings interface to set how I want this entity to display on the screen. However, I would like to add a link to another route when it is rendered. To accomplish this, I created a controller to render the sample entity outside the admin space, and added the correct link to my other entity. The problem I am now having is, I have other entities (e.g, batch) that contain entity reference links to samples. When these entities are rendered, the samples are created with links to the sample.canonical route, which is still in the admin area.
I can think of a few ways my problem could be solved. Which of these should I do?
- I can somehow modify sample.canonical to include the necessary link. (Don’t know how to do this)
- I can create a custom field formatter to render the sample with a different link.
- Alter the batch entity to use a different route when rendering Samples (don’t know how to do this)
The first option seems the most flexible. I assume I need to work with the entity twig template, which I’ve tried but have not seen any changes appear on-screen.
Any advice? Is there an easier way I don’t know about?