Override Plugin Function within theme

I have searched but have not found something to answer this question.

Is there a methodology to Override a specific function within a plugin, similar to how you deal with templates. This is due to built in structured layout which needs to be themed in a similar manner.





Marc Behiels

You can only override templates in the views directory. So if that function appears in, say, plugins/ExhibitBuilder/views/exhibits/browse.php, you can create a new template in your theme at themes/custom-theme/exhibit-builder/exhibits/browse.php and just replace the function there with a new one contained somewhere in your theme.

Thank you - unfortunately it is in the HELPERS directory so I have to over write that section of it in the actual plugin and make a note for future updates. blech…



Welcome to Omeka, @mbehiels :slight_smile:

The helper function will generally only run when called in a template, so if you create your own template and replace that function wherever it appears, you can avoid editing the plugin directly.

So if the helper function in question were, say, exhibit_builder_link_to_exhibit() and you want to change it in, say, views/public/exhibits/show.php (where it appears on line 30), you can copy that template to your theme at exhibit-builder/exhibits/show.php and just put a different function there that is defined in your theme, maybe called something like my_custom_exhibit_builder_link_to_exhibit().

Pretty sure this is the way to go, but I might be missing something.

1 Like