Fork me on GitHub

Javascript Menu inside theme?  Bottom

  • Hello All,

    I have been unsuccessfully trying to place a javascript drop-down menu into my PN Theme. The goal is to eliminate the need for the menu block and thus fre up more space. Yet for the life of me I can't seem to get the darn manu to work!? Can anyone point me to some info about this? Can this be done (javascript inside PHP?)

    Thanks
  • Outputting JavaScript to the browser is no different to PHP than outputting HTML to the browser. So it's no problem, it can be done.

    If you don't want to "roll your own" and do it yourself, there is a really slick package (see this thread), DynaMenu, that you can do this with.
  • Rem,

    It is real easy to do with an AutoTheme. I've done it with a PHP theme, but I think I had to edit the head code javascript in the the header.php file, but I can't really remember for certain. Its been that long since I bother with a PHP theme.
  • I haven't had any trouble putting Javascript into themes. It depends on the script where it needs to go. If it needs to go in the Head, as some do, you put it just after the themeheader. For example:

    Code

    function themeheader() {
        global $thename, $index, $bgcolor1, $bgcolor2;
        $slogan = pnConfigGetVar('slogan');
        $sitename = pnConfigGetVar('sitename');
        $banners = pnConfigGetVar('banners');
        $username = pnUserGetVar('uname');
    //  Place any HEADer information here, like Javascript, using echo and escaping double-quotes with \"
    echo "<script language=\"JavaScript\">
    <!--
    function toggleMenu(bid){
        var blockID = document.getElementById ? document.getElementById(bid)  // Dom
        : document.all ? document.all[bid] // ie4
        : null; // unsupported
        if (blockID == null) return;
        if (blockID.style.display==\"none\")
        blockID.style.display=\"\"
        else
        blockID.style.display=\"none\"
    }
    //-->
    </script>\n"
    ;
        echo "</head>\n";
        ?>
    <BODY>
    As mentioned, any code embedded in Echo statements must have double-quotes escaped with \"

    There are some themes which don't have the closing tag, but it should be there.

This list is based on users active over the last 60 minutes.