MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

Hide a module by default



  • Hi all,

    I try to modify an existing module to put the fonctionnality for hidden it by default when the mirror start

    explanation : i have the MMM-WiFiPassword configured on the first page, and i want it to not show when the Mirror started, and after that i can ask my assistant to show the wifi for a period.

    I know i can hide it manually with RemoteControl, but i really want it to be Hidden at the start of the mirror.

    have you an idea to help me ?

    Thanks in advance!



  • @Burnallover in whatever function in the modulename.js

    this.hide()
    

    will hide the module
    and then check in the getDom() and only return an empty div (return the wrapper with nothing in it)



  • @sdetweil thank for your response ! 🙂

    I already tried to put something like that on function :

    if (this.config.hide) {
    		this.hide()
    	}
    

    but i need some help for the getDom() part, i’m sorry i’m not a developper, can you give me an example of what it should be? sorry for my english, i’m french…



  • @Burnallover getDom() needs to return something, but u don’t want your content displayed. so

    hidden: false, 
    
    
    suspend: function(){
        this.hidden=true
    },
    
    restore: function(){
         this.hidden=false
    },
    
    notificationReceived: function(notification, payload, source){
       // this comes before the first call to getDom()
       if(notification === "ALL_MODULES_STARTED")
          this.hidden=true;
    }.
    
    getDom: function (){
    var wrapper=document.createElement('div')
    if(this.hidden==false){ 
         //create normal content
    }
    return wrapper;
    },

Log in to reply