Jump to content

How to disable an app for a specific theme


Go to solution Solved by Daniel F,

Recommended Posts

Posted (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 by Darth Vortex
Typo
Posted
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.

Posted
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.

Posted
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

Posted
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?

Posted

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. 

  • Solution
Posted

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! 

Posted
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'

 

Posted
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

Posted
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.

Posted
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?

  • Recently Browsing   0 members

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