edward-shen / MMM-pages

Add pages to your MagicMirror²!
MIT License
109 stars 29 forks source link

Using a module multiple times #61

Closed Welldoor closed 3 years ago

Welldoor commented 3 years ago

I just wonder, maybe this isn't a feature request in first place and I just missed something.

Eg. I have two pages sport work

I need my sport events on the sport page and the work events on the work page.

How to configure MMM-pages to show up two different calendar sessions, but both with the same module?

I also want to use two instances of MMM-BackgroundSlideshow, so on the sport page it is sliding through sport pictures and on work page it is sliding work motivation pictures or whatsoever...

edward-shen commented 3 years ago

Just have two instances of the same module in your config.js with different names. You can configure them separately and have each show up on different pages.

Welldoor commented 3 years ago

This means to clone/save it two times in my modules folder, right? Otherwise haven't found anything to give my modules names, wether here nor in the MM documentation.

Thank you!

edward-shen commented 3 years ago

Yeah, it's not really well documented on the magic mirror docs but that'll let you do what you want!

edward-shen commented 3 years ago

I'm closing this issue due to old age. Please feel free to reopen this issue if you still have a problem.

brettshumaker commented 3 years ago

You can load different instances of the same module on different pages by using the classes module attribute. Then use the value in your page declaration. The catch is that each instance of the module needs to have a unique value in classes to select by, and then you'll have to use that unique value (not the default module name) when including it in your pages.

Here's an example:

{
    module: 'MMM-pages',
    config: {
        modules: [
            [
                'clock-default'
            ],
            [
                'clock-analog',
            ],
        ],
    }
},
...
{
    module: "clock",
    position: "top_left",
    classes: 'clock-analog',
    config: {
        clockBold: true,
    },
},
{
    module: "clock",
    position: "top_left",
    classes: 'clock-default',
    config: {
        displayType: 'analog',
    },
},