Overriding Core Modules
Created 5 years ago by johnny5

Hi,

I can't seem to get Pyro 3.5 to override core classes. I wish to set a different meta title on the /posts page. I'm my theme service provider I've added: protected $bindings = [ \Anomaly\PostsModule\Post\Command\AddPostsMetaTitle::class => \MyCompany\MyTheme\Post\AddPostsMetaTitle::class, ]; I have my own version of AddPostsMetaTitle within my theme folder as per above, but the title doesn;t change, even after manually clearing the Twig cache. I've also tried {% set meta_title = 'test' %} directly within my own posts template (I've managed to override module views without issue). Are there any example of overriding core modules? Thanks

ryanthompson  —  5 years ago

These classes aren't always resolved out of the IoC container. What I do in this particular case is php artisan addon:publish posts and edit the language files I need to change the terms. Then I delete all the other files so there is only overriding for what I want to change.

johnny5  —  5 years ago

@ryanthompson Thanks for the reply. How would I edit say https://github.com/anomalylabs/posts-module/blob/2.4/src/Http/Controller/PostsController.php - I have a request from a client's SEO company that posts need to have a canonical tag set. I can do this easily by editing the core file directly, but I'd to avoid this if possible.

ryanthompson  —  5 years ago

Isn't the conical tag just the current link? If so that can be done in the metadata with something like {{ request_url() }}