• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Except a module in getModules()

Scheduled Pinned Locked Moved Troubleshooting
14 Posts 3 Posters 5.2k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    yours.mukul @strawberry 3.141
    last edited by Sep 10, 2017, 8:33 AM

    @strawberry-3.141 how to iterate over the modules array ?
    I want to show/hide all modules except the “helloworld”.

    ? S 2 Replies Last reply Sep 10, 2017, 8:56 AM Reply Quote 0
    • ? Offline
      A Former User @yours.mukul
      last edited by A Former User Sep 10, 2017, 8:56 AM Sep 10, 2017, 8:56 AM

      @yours.mukul

      MM.getModules().enumerate((module)=>{
        if(module.name !== "helloworld") {
          module.hide()
        }
      })
      

      This is written by hand, so there might be error, but you can understand how it goes.

      1 Reply Last reply Reply Quote 0
      • S Offline
        strawberry 3.141 Project Sponsor Module Developer @yours.mukul
        last edited by Sep 10, 2017, 10:08 AM

        @yours.mukul enumerate will iterate over the array and will execute the function you specify for each module in the array

        Please create a github issue if you need help, so I can keep track

        1 Reply Last reply Reply Quote 0
        • Y Offline
          yours.mukul @strawberry 3.141
          last edited by Sep 10, 2017, 2:56 PM

          @strawberry-3.141 Well your code didn’t hide any of modules

          S ? 2 Replies Last reply Sep 10, 2017, 4:01 PM Reply Quote 0
          • S Offline
            strawberry 3.141 Project Sponsor Module Developer @yours.mukul
            last edited by Sep 10, 2017, 4:01 PM

            @yours.mukul do you get any errors?

            Please create a github issue if you need help, so I can keep track

            Y 1 Reply Last reply Sep 10, 2017, 6:17 PM Reply Quote 0
            • ? Offline
              A Former User @yours.mukul
              last edited by A Former User Sep 10, 2017, 4:13 PM Sep 10, 2017, 4:10 PM

              @yours.mukul
              In .exceptModule(someModule), someModule should be an instance of module object. It means you should get the object first before enumerating.
              Usually, you can get module object instance with notification. In other way, you should enumerate all modules first, filter them by name(or any other condition), after then you can use those objects for .exceptModule() as parameter.

              So I think you’d better examine other modules how they handle this. Not so difficult.

              1 Reply Last reply Reply Quote 0
              • Y Offline
                yours.mukul @strawberry 3.141
                last edited by Sep 10, 2017, 6:17 PM

                @strawberry-3.141 No there were no errors but I didn’t hide my modules

                1 Reply Last reply Reply Quote 0
                • 1
                • 2
                • 2 / 2
                2 / 2
                • First post
                  12/14
                  Last post
                Enjoying MagicMirror? Please consider a donation!
                MagicMirror created by Michael Teeuw.
                Forum managed by Sam, technical setup by Karsten.
                This forum is using NodeBB as its core | Contributors
                Contact | Privacy Policy