Jump to content

Add custom HTML before div#pw-mastheads if in debug mode


DrQuincy
 Share

Recommended Posts

I have had a client say that because the dev and live hosts are so similar they get confused between the development and production CMSs. They have asked for a way to make it clearer which environment they're in.

Although it says “The site is in debug mode, suitable for sites in development” in yellow when you log in on the dev version I think they are wanting something more obvious.

An easy solution would be to add a message at the top of the page in debug mode. After messing around with Inspect element it seems if I could insert custom HTML before div#pw-mastheads that would do the trick.

Is there a hook for this? I could do it with custom JS but is there any way to tell from the DOM or an existing JS variable if it's in debug mode?

Thanks.

Link to comment
Share on other sites

Hey @DrQuincy

in site/templates/admin.php you could do somthing like this:

<?php $wire->addHookAfter('AdminTheme::getExtraMarkup', function(HookEvent $event) {
   
    $parts = $event->return;
	$markup = '';
	
	if((wire('config')->debug) == true) $markup = '
        <div class="pw-container uk-container uk-container-expand">
            <div class="uk-alert uk-alert-danger">Your in Debug Mode!</>
        </div>';
    
    $parts['masthead'] .= $markup;
    $event->return = $parts;
  
});?>

Perhaps you could even check the $config->httpHosts if you want to.

I hope this'll help you ? Many greets!

  • Like 4
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...