Jump to content

RockDevTools livereload only in frontend


gebeer
 Share

Recommended Posts

Hi @bernhard,

is it possible to enable livereload only for frontend, like it used to be in RockFrontend? I think there was a switch in the GUI to enable it for backend.

Now we only have the $config->rockdevtools = true; setting.

Do we need to hook somewhere (maybe Page::render) to set it to false if template == admin, or something like this?

Where to place the hook?

I see in bot RockDevTools class and LiveReload class the check for the config value is in the constructor. So we would have to hook before the RockDevTools module is loaded, right?

Or is there an easy solution, that I overlooked? The docs don't mention anything.

Having reload in the backend can sometimes be annoying, e.g. when working on migrations and saving a file with unfinished migration or copying an existing migration file for reuse etc.

Some control here would be much appreciated.

  • Like 1
Link to comment
Share on other sites

9 hours ago, bernhard said:

Hey @gebeer I have added support for this on the dev branch, please check 🙂 

Here are the docs: https://github.com/baumrock/RockDevTools/tree/dev/docs/livereload#disabling-livereload-for-specific-pages

That was quick. Thank you!

I added a config checkbox in my Site.module to toggle behavior and added this to the hook function:

	/**
	 * Switch LiveReload for backend based on module setting
	 * @param HookEvent $event
	 */
	public function switchLiveReloadBackend(HookEvent $event)
	{
		$page = $event->arguments(0);
		$enable = $this->wire->config->isDev && (bool) $this->liveReloadBackend;
		if ($page->template == 'admin') $event->return = $enable;
	}

image.png.8b26c5995992c03f396eea81ab650db1.png 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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