Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Site-specific Javascript

Site-specific Javascript

Scheduled Pinned Locked Moved General Discussion
15 Posts 4 Posters 2.3k Views 2 Watching
  • 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.
  • L
    L
    lars
    wrote on last edited by
    #3

    Hi @mariusjopen

    Here is the website:
    https://strategis.de

    And as I mentioned it only applies to the mobile version.

    The pages „legal notice/Impressum“ and „privacy/Datenschutz“ can be found inside the burger menu.

    Best
    Lars

    1 Reply Last reply
    0
    • mariusjopenM
      mariusjopenM
      mariusjopen
      Global Moderator
      wrote on last edited by
      #4

      Dear @lars

      does this simple example work?

      <script>
      window.laytheme.on("newpageshown", function(layoutObj, type, obj){
      	if(type == "project" && obj.id == 1){
      		console.log("fantastic!");
      	}
      });
      </script>
      

      Do you get a console log?

      Best!
      Marius

      www.mariusjopen.world

      1 Reply Last reply
      0
      • L
        L
        lars
        wrote on last edited by
        #5

        Dear @mariusjopen

        I added the script in the custom head section.

        When I visit the project site by entering the URL or coming from the WP backend I get the console log.

        However if I set a link to this project on another page of my website and click on it, the log is not showing up.

        It seems as if the site needs to be reloaded entirely before the script fires.

        1 Reply Last reply
        0
        • RichardR
          RichardR
          Richard
          Global Moderator
          wrote on last edited by
          #6

          Dear @lars

          Thank you for your patience, forgive me for the late reply

          I will forward this To Armin so we can take a better look

          Thank you for using Lay Theme

          Sincerely
          Rich

          1 Reply Last reply
          0
          • arminunruhA
            arminunruhA
            arminunruh
            Global Moderator
            wrote on last edited by arminunruh
            #7

            Ok lol
            I re-read ur text and I think there's probably nothing wrong with the detection of the correct page.
            However, of course u need to remove your functionality on the other pages so I think ur code/ur logic is wrong.

            U should do:

            <script>
            window.laytheme.on("newpageshown", function(layoutObj, type, obj){
            	if(type == "page" && obj.id == 86){
            	    jQuery('.mobile-title').addClass('scrolltotop');
            	}else{
                       jQuery('.mobile-title').removeClass('scrolltotop');
                    }
            });
            </script>
            
            1 Reply Last reply
            0
            • L
              L
              lars
              wrote on last edited by
              #8

              Dear @arminunruh

              thanks that totally makes sense! I replaced the script on the site and it works.

              I checked it with the web inspector and the class .scrolltotop is getting added and removed accordingly.

              However the same behaviour as stated in the first post still exists.

              If you go to https://strategis.de/impressum/ directly, or reload the page, the logo links back to home. If you however go from the home page to the site (via the burger menu) the logo still acts as a scroll to top button.

              1 Reply Last reply
              0
              • L
                L
                lars
                wrote on last edited by
                #9

                Okay another observation:

                Today I added a new page „Kontakt“ and put it in the mobile menu like Impressum and Datenschutz beforehand.

                For whatever reason the script works as intended when going from the main page to the „Kontakt“ page through the burger menu and vice versa. On „kontakt“ the logo is linking back to the main page.

                Also see the difference in the transition between clicking on „Impressum“, „Datenschutz“ or „Kontakt“. The click on „Kontakt“ seems to trigger a reload whereas the other two just chance the displayed content.

                Any chance to replicate this behaviour to the other menu points?

                1 Reply Last reply
                0
                • RichardR
                  RichardR
                  Richard
                  Global Moderator
                  wrote on last edited by
                  #10

                  Dear @lars

                  Checking in :)

                  Did you find a solution to your problem or does the issue still persist!

                  Best wishes and have a great day

                  Sicnerely
                  Richard

                  1 Reply Last reply
                  0
                  • L
                    L
                    lars
                    wrote on last edited by
                    #11

                    Dear @Richard-Keith

                    thanks for checking in.
                    Unfortunately I haven’t found a solution yet.

                    Like I stated in my post 12 days ago about the „Kontakt“ the script works fine as long as the page is properly (re)loaded in the browser. But it is not working when a transition from one page to another is invoked.

                    Any way to tell the Laytheme Single Page JavaScript application to not transition but instead to reload a new page?

                    1 Reply Last reply
                    0
                    • RichardR
                      RichardR
                      Richard
                      Global Moderator
                      wrote on last edited by Richard
                      #12

                      Dear @lars

                      Apologies that you haven't found a solution,
                      I will forward this straight away so we can find one faster :)

                      In the meantime if you could please send your website address, /wp-admin/ username and password and a link to this topic to info@laytheme.com? to speed up the process.

                      Hope you have a wonderful day and thank you for being a part of the Community.

                      Best wishes
                      Richard

                      1 Reply Last reply
                      0
                      • arminunruhA
                        arminunruhA
                        arminunruh
                        Global Moderator
                        wrote on last edited by
                        #13

                        Any way to tell the Laytheme Single Page JavaScript application to not transition but instead to reload a new page?

                        Hey @lars apologies for not getting back to you earlier. My support coworker is new and just started out.
                        Yes you can make lay theme reload on every page load.
                        Go to Lay Options and at the bottom activate "Disable Ajax / Compatibility Mode"

                        1 Reply Last reply
                        0
                        • L
                          L
                          lars
                          wrote on last edited by
                          #14

                          Hey @arminunruh no problem!

                          Your suggestions finally did the trick.
                          The script is working as intended.

                          Thank you very much.

                          Best
                          Lars

                          1 Reply Last reply
                          0
                          • RichardR
                            RichardR
                            Richard
                            Global Moderator
                            wrote on last edited by
                            #15

                            Dear @lars

                            Thanks for Getting back and confirming your success,

                            Best Wishes & Thank you for using Lay Theme!
                            Richard

                            1 Reply Last reply
                            0

                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                            With your input, this post could be even better 💗

                            Register Login
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            Online Users
                            A
                            Anna_S
                            Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
                            laytheme.com
                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Search