Roots Discourse

Overwriting template files from plugins

I’m looking for one day and didn’t find an answer so I try here…

I want to use blade for overwriting template files from plugins in my Sage theme.

My case: I use the YARPP plugin to show related posts to the current post. I can use a shortcode for this.
The documentation of the plugin says you can overwrite the html of the result if you copy a file in your theme. If I check this option the plugins copy the template file ‘yarpp-template-thumbnail.php’ to my resources folder.

But I want to use blade and use my other blade templates to include, use Controller code, …

I tried:

  • renaming the template file to …blade.php
  • Looked into the filter hook ‘template_include’

So in general, what is the way of working if you want to use the power of sage in template parts you want to override of plugins…

Thanks in advance!

Or maybe a way is to use this template file that is suggested and include a blade file via php in this template file? To redirect to a blade file?

Yes, you need to use this suggested template file.
There you can “include” blade file using template() helper function.
In your example ‘yarpp-template-thumbnail.php’ file should look like this:

use function App\template;
echo template('blade-template-name');

This topic was automatically closed after 42 days. New replies are no longer allowed.