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

static text to MM2



  • Hey @ all,

    I´m a freshy at raspberrypi and I copied the “helloworld”-module to create a static-text-module with a name “MMM-static-text” just to avoid any problems in future if someone changes the “helloworld” for any reasons.
    I changed the names of the folder, files and within the file to “MMM-static-text”
    MMM-static-text.js:

    /* global Module */
    
    /* Magic Mirror
     * Module: MMM-static-text
     *
     * By Michael Teeuw http://michaelteeuw.nl
     * MIT Licensed.
     */
    
    Module.register("MMM-static-text",{
    
    	// Default module config.
    	config: {
    		text: "Wetterinformationen"
    	}
    });
    

    config.js:

    {	module: "MMM-static-text",
    			position: "top_right",
    			config:{
    				text: "Wetterinformationen"
    			}
    		},
    

    Unfortunatelly it doesn´t show “Wetterinformation”. Instead it shows “MMM-static-text” and below “module_4_MMM-static-text”. If I use the helloworld-module it is the same.
    What is wrong with my module?
    Thanks for any help.
    Best Regards
    Daniel


  • Moderator

    Did you change all files in modules/default? Or did you create a folder MM-static-text in modules ?



  • Hi @yawns

    I copied the complete helloworld-folder from modules/default to modules and renamed it to MMM-static-text.
    I renamed all files as well.
    This is the outcome…
    0_1530605311658_Forum.png


  • Moderator

    Ah, I see. The module is missing the code to actually display/do something, either directly or via template system.

    /* global Module */
    
    /* Magic Mirror
     * Module: MMM-static-text
     *
     * By Michael Teeuw http://michaelteeuw.nl
     * MIT Licensed.
     */
    
    Module.register("MMM-static-text",{
    
    	// Default module config.
    	defaults: {
    		text: "Wetterinformationen!"
    	},
    
    	// Override dom generator.
    	getDom: function() {
    		var wrapper = document.createElement("div");
    		wrapper.innerHTML = this.config.text;
    		return wrapper;
    	}
    });
    


  • Hi @yawns ,

    thanks a lot. This works fine after I copied your code into my file.
    Just typing the rest of the missing code does´nt worked. I had to copy the code.
    I assume a missing ; or ,.
    Anyway I fixed with your help.
    Thanks a lot!


Log in to reply