0

I'm struggling to override the template on the admin interface for a content type. I'm going to need to do several modifications to the edit form to meet the editor's requirements, however, I seem to be unable to get this to override.

The page source gives me the following

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'paragraphs_summary' -->
<!-- BEGIN OUTPUT from 'modules/contrib/paragraphs/templates/paragraphs-summary.html.twig' -->

If I make a change to the twig file specified I can make my change, however, it's not my module so I shouldn't be making changes and I only want to override on specific content types so I have to go for a theme based override (which of course is the right way to do it)

I've copied this twig template to

themes/custom/my_theme/templates/paragraph--my-content-type-paragraph-type--paragraphs-summary.html.twig

and quite a number of combinations of this, rebuilt the cache with $ drupal cr yet the admin interface still gives the default template instead of my one (and yes, I have remembered to set the admin theme as my new theme).

I want to be able to have a different presentation in the admin interface to that of the anonymous visitor's view, hence looking at overriding the templates.

Any suggestions of how I can achieve this?

5
  • Turn on Twig debugging. I can't see any of those template suggestions you mention on my local install. Have you tried paragraph--PARAGRAPHTYPE--summary.html.twig ? (without parent content type!)
    – Hudri
    Sep 13, 2019 at 9:05
  • I have twig debugging on twig.config: { debug: true, auto_reload: true, cache: true } Any other settings that should be enabled? If I remove the parent content type, then won't that impact all content types, not just the one I need to change? Sep 13, 2019 at 9:14
  • Yes, this does affect all content types. But paragraphs simply does not provide a theme suggestion based on the parent node. You either have code additional theme suggestions or create a new display mode that is only used in this specific node (this can be done without custom coding)
    – Hudri
    Sep 13, 2019 at 9:50
  • Ah, it wasn't clear, I'll look at a theme suggestion, I've written many bits of custom code already and suspect there will be many more needed on this project. Sep 13, 2019 at 10:02
  • 4
    Possible duplicate of How to add the paragraph parent field in the theme suggestions alter
    – Hudri
    Sep 13, 2019 at 10:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.