Jump to content

How to disable an app for a specific theme


Go to solution Solved by Daniel F,

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

  • Solution

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! 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...