ReyDev Posted August 22, 2021 Posted August 22, 2021 I have an app that changes the navigation but i want to disable it for specific theme. how can i do it ?
WP V0RT3X Posted August 22, 2021 Posted August 22, 2021 (edited) Go to a member profile in AdminCP and click on Edit Preferences. There you can find such a theme choser. I use it in a some of my plugins. Edited August 22, 2021 by Darth Vortex Typo
ReyDev Posted August 22, 2021 Author Posted August 22, 2021 13 minutes ago, Darth Vortex said: Go to a member profile in AdminCP and click on Edit Preferences. There you can find such a theme choser. I use it in a some of my plugins. thanks, But there is no option for this. I actually want to prevent hooking up classes on a particular theme.
WP V0RT3X Posted August 22, 2021 Posted August 22, 2021 You want the user to select the themes the plugin is active, right? Then take a look at the code and you have what you want.
Adriano Faria Posted August 26, 2021 Posted August 26, 2021 On 8/22/2021 at 5:37 AM, ReyDev said: I have an app that changes the navigation but i want to disable it for specific theme. how can i do it ? I'm not sure if you want this to be used in your board only or if you want to release something and exclude an app from a theme, so here goes a hard coded way. In the \IPS\yourApp\Application::init(), add: /** * Init * * @return void */ public function init() { if( \IPS\Dispatcher::i()->controllerLocation === 'front' ) { \IPS\Theme::switchTheme( X ); } } This will force the app to run in another theme. X is the ID of the theme.
ReyDev Posted August 27, 2021 Author Posted August 27, 2021 11 hours ago, Adriano Faria said: I'm not sure if you want this to be used in your board only or if you want to release something and exclude an app from a theme, so here goes a hard coded way. In the \IPS\yourApp\Application::init(), add: /** * Init * * @return void */ public function init() { if( \IPS\Dispatcher::i()->controllerLocation === 'front' ) { \IPS\Theme::switchTheme( X ); } } This will force the app to run in another theme. X is the ID of the theme. thanks @Adriano Faria I'll work on it and let you know
ReyDev Posted August 27, 2021 Author Posted August 27, 2021 12 hours ago, Adriano Faria said: I'm not sure if you want this to be used in your board only or if you want to release something and exclude an app from a theme, so here goes a hard coded way. In the \IPS\yourApp\Application::init(), add: /** * Init * * @return void */ public function init() { if( \IPS\Dispatcher::i()->controllerLocation === 'front' ) { \IPS\Theme::switchTheme( X ); } } This will force the app to run in another theme. X is the ID of the theme. @Adriano Faria This code does not work because this app does not have a controller on the front location I just want to prevent the code of this app from being hooked on a particular theme is there a way to disable an app by code?
Adriano Faria Posted August 27, 2021 Posted August 27, 2021 It doesn’t need to have a front end controller and I never mentioned it. You need to hook in the Applications.php, which ALL apps must have! Fromt there will work everywhere, including when a hook from this app runs. Anyway, to disable an app, use: $app = \IPS\Applications::load( ‘appkey’ ); $app->enabled = 0; $app->save(); Not tested. Doing in on a phone. ReyDev 1
Solution Daniel F Posted August 27, 2021 Solution Posted August 27, 2021 Adriano's code will disable the app completely, which I guess is also not what you want:D 1. You'll have to tell us how you're changing the navigation:D 2. You *could* use \IPS\Member::loggedIn()->skin to get the members theme id and do something like: {{if \IPS\Member::loggedIn()->skin === 3}} this will be displayed only in theme 3 {{else}} everybody else will see this {{endif}} Something similar could be done in Theme::hookData(). It's really a powerful system, so I would suggest to spend some time to see how exactly it's working:) You could also create a hook on Template::compileTemplate to do whatever you want there, for example to remove the hook before the template is compiled;) BUT I'm afraid, that's just asking for trouble and it's something what you could do for your own board, but I don't think that we would allow such changes in the marketplace! ReyDev, Adriano Faria and Gregory Gleinig 2 1
Adriano Faria Posted August 27, 2021 Posted August 27, 2021 I’m struggling to understand the issue there. 😀
ReyDev Posted August 27, 2021 Author Posted August 27, 2021 44 minutes ago, Adriano Faria said: t doesn’t need to have a front end controller and I never mentioned it yes, you didn't mention it but this code means : \IPS\Dispatcher::i()->controllerLocation === 'front'
ReyDev Posted August 27, 2021 Author Posted August 27, 2021 10 minutes ago, Daniel F said: Adriano's code will disable the app completely, which I guess is also not what you want:D 1. You'll have to tell us how you're changing the navigation:D 2. You *could* use \IPS\Member::loggedIn()->skin to get the members theme id and do something like inside your templates: {{if \IPS\Member::loggedIn()->skin === 3}} this will be displayed only in theme 3 {{else}} everybody else will see this {{endif}} Something similar could be done in Theme::hookData(). It's really a powerful system, so I would suggest to spend some time to see how exactly it's working:) You could also create a hook on Template::compileTemplate to do whatever you want there, for example to remove the hook before the template is compiled;) BUT I'm afraid, that's just asking for trouble and it's something what you could do for your own board, but I don't think that we would allow such changes in the marketplace! thanks @Daniel F as you know i have Menu plus and Search overlay apps. i recently released LAXERI theme that has own search and navigation. in my board (ips.valacoding.com) i want to disable these two apps for the LAXERI them that the visitors see the LAXERI navigation and search plugin. it's just for demo version 14 minutes ago, Daniel F said: Something similar could be done in Theme::hookData(). It's really a powerful system, so I would suggest to spend some time to see how exactly it's working:) I will definitely take a look
Adriano Faria Posted August 27, 2021 Posted August 27, 2021 7 minutes ago, ReyDev said: yes, you didn't mention it but this code means : \IPS\Dispatcher::i()->controllerLocation === 'front' No. It means that will run in any place of the front end, not specifically in a controller. It can be a hook, a ModeratorCP extension, etc.
ReyDev Posted August 27, 2021 Author Posted August 27, 2021 1 hour ago, Daniel F said: You could also create a hook on Template::compileTemplate to do whatever you want there thanks @Daniel F this exactly what i was looking for. as far as i realized , all hooks are in \IPS\IPS::$hooks. i can remove any hook from it with the unset method. but i just wanted to know is there a helper or method in IPS which do it?
Daniel F Posted August 27, 2021 Posted August 27, 2021 Nope, there's no official helper method:) ReyDev 1
Recommended Posts