HISE Logo Forum
    • Categories
    • Register
    • Login

    Fetch data from json file to wordpress

    Scheduled Pinned Locked Moved General Questions
    11 Posts 6 Posters 1.4k Views
    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.
    • Christoph HartC
      Christoph Hart
      last edited by

      This post is deleted!
      1 Reply Last reply Reply Quote 0
      • ?
        A Former User
        last edited by A Former User

        I found this fetch method. Let's say the json file link is: https://testsite.com/myproductversion.json

        fetch('https://testsite.com/myproductversion.json').then(res => res.json())
        .then(({ MajorVersion, MinorVersion, MaintenanceVersion }) => {
          let version = `v${MajorVersion}.${MinorVersion}.${MaintenanceVersion}`;
          $('.my-version-goes-here').html(version);
        }).catch(console.error);
        

        How this method can be used in html?

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @A Former User
          last edited by d.healey

          @Steve-Mohican HTML is not a programming language, you can't do things like that with it. I recommend you hire a WordPress developer on fivver.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          1 Reply Last reply Reply Quote 0
          • LindonL
            Lindon @A Former User
            last edited by

            @Steve-Mohican - just use a text editor on your own machine then upload it with an FTP client.

            HISE Development for hire.
            www.channelrobot.com

            1 Reply Last reply Reply Quote 2
            • FortuneF
              Fortune
              last edited by Fortune

              @Steve-Mohican Did you find a solution for this?

              LindonL ? 2 Replies Last reply Reply Quote 0
              • LindonL
                Lindon @Fortune
                last edited by

                @Fortune said in Fetch data from json file to wordpress:

                @Steve-Mohican Did you find a solution for this?

                the solution is right above your post....

                HISE Development for hire.
                www.channelrobot.com

                1 Reply Last reply Reply Quote 1
                • ?
                  A Former User @Fortune
                  last edited by

                  @Fortune said in Fetch data from json file to wordpress:

                  @Steve-Mohican Did you find a solution for this?

                  @Fortune Not yet. I haven't hired a developer for that. But I plan to find one in fiverr like @d-healey advised.
                  After that I will follow to upload with an FTP client like @Lindon

                  1 Reply Last reply Reply Quote 0
                  • orangeO
                    orange
                    last edited by orange

                    @Steve-Mohican @Fortune
                    Here you go :D There could be a better implementation, but this is what I use for this purpose.

                    Below is the HTML code, I don't know which wordpress composer plugin you're using but you need to put this code into an HTML editor (standart Gutenberg Text editor might not work). Then you need to upload your json file (named as version.json here) into your server just like @Lindon said.

                    Also you need to customize your div, .p and .currentversiondisplayer css styles (the container div tag is versiondisplayer_container here)

                    If you don't want to work online at the begining, you can use XAMPP for local server system by the way ;)

                    <script src="https://code.jquery.com/jquery-3.6.0.js" crossorigin="anonymous"></script>
                    
                    <div class="versiondisplayer_container">
                    <p>Current Version: </p> <p id="productA_currentversiondisplayer"></p> 
                    </div>
                    
                    
                    <script>
                    $(document).ready(function() {
                    fetch('/SubFolderOfTheJsonFile/version.json')
                      .then(response => response.json())
                      .then(data => $('#productA_currentversiondisplayer').html((data.MajorVersion+'.'+data.MinorVersion+'.'+data.MaintenanceVersion)));
                    });
                    </script>
                    

                    Like you want, the JSON file is this:

                    {
                      "Name": "MyProduct",
                      "MajorVersion": "1",
                      "MinorVersion" : "0",
                      "MaintenanceVersion" : "0"
                    }
                    

                    Example usage is here (shows up in the "Current Version" section): https://www.noiseash.com/downloads/

                    develop Branch / XCode 13.1
                    macOS Monterey / M1 Max

                    ? FortuneF 2 Replies Last reply Reply Quote 1
                    • ?
                      A Former User @orange
                      last edited by

                      @orange Wow! That's it man :D
                      Thank you so much!!!! 👑 👑 👑

                      1 Reply Last reply Reply Quote 0
                      • FortuneF
                        Fortune @orange
                        last edited by

                        @orange thanks a lot dude, you're awesome :)

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        20

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        102.5k

                        Posts