Override Core By Package Only One Theme

Permalink
Hi community!

Here's situation :
- I have two theme.
- I used 'override core block controller in package' like this :-

public function on_start() {
$objEnv = Environment::get();
$objEnv->overrideCoreByPackage('elements/pages/search.php', $this);
}

So here's my question :
How do I override core 'search.php' in package only 'one' theme? ...

Any kind of help appreciated.

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi nasir88,

Are the two themes and the override in the same package?

You could create a separate package with the override and the theme you want to use the override.

If they are in the same package, maybe you could try this.
- conditionally add the override based on the current theme being used
public function on_start() {
   $currentSiteTheme = PageTheme::getSiteTheme();
   if ($currentSiteTheme->getThemeHandle() === 'yourthemenhandle') {
      $objEnv = Environment::get();
      $objEnv->overrideCoreByPackage('elements/pages/search.php', $this);
   }
}
nasir88 replied on at Permalink Reply
Hi MrKDilkington,

Wonderful... I have create the same package .
I will have a look at this. Thank you for your reply.