HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

Load alternative default.master.tpl?

cmccarracmccarra New
edited August 2012 in Vanilla 2.0 - 2.8

I'm trying to create a custom page that has a google map in it but I need to add a lot of javascript to the head. I don't want to have it loading in pages its not being used in so I'm not going to add it to the default.master.tpl. Is there a way to create another master - something like map.master.tpl where I can then load the javascript and customise the rest of the page?

Basically I want to these two pages - http://connormccarra.com/test/ and http://connormccarra.com/test/add - working inside the style of my forum (which is using the VanillaBootstrap theme). Any suggestions? I tried the plugins none of them seem to work very smoothly.

Comments

  • 422422 Developer MVP
    edited August 2012

    Use custom pages plugin, and set up routes.

    Check my air theme in my signature, and click on contact to see what i mean.

    UnderDog
  • peregrineperegrine MVP
    edited August 2012

    You could modify the add menu item plugin.

    and just selectively add the javascript to the pages you want based on the $Sender->SelfUrl

    it seems simple enough.

    But why don't you add the javascript in the test and test/add pages.
    and selectively add the links to the pages in the default.master.tpl

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • I starting messing about with the Custom Pages plugin and I have it setup exactly the way I wanted fairly easily. It takes awhile for you to get round how Custom Pages works. Problem was google maps normally use body onload(), got round it by using the below fix, with a few other changes:

     <script type="text/javascript"> 
      function addLoadEvent(func) {
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
        window.onload = func;
      } else {
        window.onload = function() {
          if (oldonload) {
            oldonload();
          }
          func();
        }
      }
    }
    
    addLoadEvent(load);
    
    // arrange for our onunload handler to 'listen' for onunload events
    if (window.attachEvent) {
            window.attachEvent("onunload", function() {
                    GUnload();      // Internet Explorer
            });
    } else {
    
            window.addEventListener("unload", function() {
                    GUnload(); // Firefox and standard browsers
            }, false);
    
    }
      </script>
    

    You can see what I have done here: http://poultry.ie/plugin/page/breeders, I have yet to setup routes but all in good time :)

    422UnderDog
  • 422422 Developer MVP

    I like your add a breeder grab lat and long. Couldnt you use get location. Also validation on submit breeder needs fixing but looks cool. Good work

    UnderDog
  • I don't feel get location is accurate enough yet. The way it is now allows the breeder to put the marker right up to their doorstep, so to speak which is very useful for directions.

Sign In or Register to comment.