Using a plugin snippet from another plugin

I created a plugin to display images the way i want. This is the plugin’s structure:

  • image-plugin
    • blueprints
      • image.yml
    • snippets
      • image.php
    • index.css
    • index.js
    • index.php

I created another plugin that renders testimonials the way i want. It looks pretty much the same in terms of structure:

  • testimonials-plugin
    • blueprints
      • testimonial.yml
    • snippets
      • testimonial.php
    • index.css
    • index.js
    • index.php

The testimonial-plugin displays some text and an image. I would like to use the image-plugin/snippets/image.php as its image-renderer. How is that possible?

I tried this and its not working: <?php snippet('image-plugin/image', [myparams_here]); ?>

You would just call the snippet by it’s name as usual. But note that plugins that depend on each other are a bit tricky because of their loading order (which is alphabetically).

You should also keep in mind that snippets in the site folder overwrite plugin snippets, so maybe giving your snippets less general names than image would make sense.

Thanks. Indeed the naming “image” caused the system to override my plugin file.