Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

How do I add a script in the header?

BenBen
edited July 2005 in Vanilla 1.0 Help
I want to add the following line into the header on all pages, unfortunately I can't seem to find where I would put this... <script type="text/javascript"> <!-- if( top != self ){ top.location=self.document.location; } //--> </script> It's to break the page out of frames as otherwise the login doesn't work on my server.

Comments

  • Options
    jonezyjonezy New
    edited July 2005
    you could write an extension i imagine...

    if (@$Head) { $Head->AddScript($Context->StyleUrl."framebreaker.js"); }

    and then have your js in an external file.

    i looked at the PanelHider extension and just quickly edited it down.
  • Options
    again, the documentation for extensions isn't available just yet.
  • Options
    MarkMark Vanilla Staff
    edited July 2005
    If I were you, I'd put my javascript into a .js file. Then create a new extension following the same comment methods adopted by existing extensions (ie. name it, version number, your name, etc) and then the only real php you'll need to add is this:

    $Head->AddScript("/path/to/your/js/file.js");
  • Options
    wow did we just say the same thing but different?
  • Options
    MarkMark Vanilla Staff
    There ya go. *wipes brow*
  • Options
    BenBen
    edited July 2005
    ok... I've created the following.

    My Extension
    <?php /* Extension Name: Break Frames Extension Url: http://soul-scape.com/ Description: Should add a script on every page to allow the site to break free from the constricting frames. Version: 1.0 Author: Ben Author Url: http://www.soul-scape.com/ */ $Head->Addscript("./js/BreakFrames.js"); ?>

    My Javascript
    if( top != self ){ top.location=self.document.location; }

    Now this still doesn't seem to be working, I'm not familiar with the intricacies of JavaScript so any help would be appreciated... :)
  • Options
    did you enable it in the admin? can we see a page where it would be ?
  • Options
    just looking at your login page, it says that the file doesn't exist on the server? are you sure you uploaded it?
  • Options

    while you're at it, give me a discussion list auto-refresher! ;)

  • Options
    omg use the feed :X
  • Options
    jonezyjonezy New
    edited July 2005
    /* Extension Name: Break Frames Extension Url: http://soul-scape.com/ Description: Should add a script on every page to allow the site to break free from the constricting frames. Version: 1.0 Author: Ben Author Url: http://www.soul-scape.com/ */ if (in_array($Context->SelfUrl, array("index.php")) && $Context->Session->UserID > 0) { $Head->Addstring("META TAG TO REFRESH THE PAGE"); } ?>

    thhat would probably work
  • Options
    Hmm, during uploading, it seems to have renamed the file to lowercase. Just adjusting the reference in the extension to lowercase has fixed it. Thanks very much jonezy
  • Options
    ahh, now it's producing a header error message...

    Warning: Cannot modify header information - headers already sent by (output started at /home/soul-sca/public_html/vanilla/extensions/BreakFrames.php:15) in /home/soul-sca/public_html/vanilla/library/Vanilla.Session.class.php on line 27
  • Options
    maybe try wrapping the if statement around it.

    if (@$Head) { }
  • Options
    omfgomfg New
    edited July 2005
    465446543217
  • Options
    for some reason, just re-uploading the file worked as well the problem seems to be solved, thanks everyone
  • Options
    you are welcome ben.
This discussion has been closed.