Menu

Hack for Top-Navigation

2004-12-01
2013-03-26
  • Niels Christian

    Niels Christian - 2004-12-01

    I hope that this is the right place to post a little hack? Ah well - see, I want to give my Jetbox-Site a complete facelift. Which is difficult enough as the HTML-parts are spreaded all over the different include-files.

    Never mind.

    I stumbled over the function for building the Top-Level-Navigation. The function is called "topnav" and is located in the file "index.php" - however I found it pretty anoying to have to change 5 lines of same HTML-Code - so here is my little hack - just change the complete function into:

    // opentree top navigation
    // no template support yet 28-3-2003
    function topnav(){
        global $wfqadd, $absolutepath, $absolutepathfull;
       
        function buildTopNav ($topNavURL, $topNavTitle, $topNavTarget, $topNavText) {
            global $absolutepath;
            $toReturn = "<td><img src=\&quot;".$absolutepath."images/navbar.gif\&quot; alt=\&quot;\&quot;></td><td>&nbsp;<a href=\&quot;".$topNavURL."\&quot; title=\&quot;".$topNavTitle."\&quot; target=\&quot;".$topNavTarget."\&quot;>".$topNavText."</a>&nbsp;&nbsp;&nbsp;</td>\n";
            return ($toReturn);
        }
        $a.= "<table class=\&quot;white\&quot; border=0 cellpadding=0 cellspacing=0><tr>";
        $a.= buildTopNav (absolutepathfull,"Home","_self","Home");
       
        $treeq = "SELECT struct.*, opentree.*, struct.id AS structid, opentree.page_title AS pagetitle FROM struct, opentree WHERE opentree.p_id='' ".$wfqadd." AND struct.container_id=11 AND struct.content_id=opentree.id AND opentree.top_nav=1";
        $treer = mysql_prefix_query($treeq) or die(mysql_error());
        while ($treearray = mysql_fetch_array($treer)){
            $a.= buildTopNav ($absolutepathfull."item/".$treearray[structid],$treearray[pagetitle],"_self",$treearray[nav_title]);
        }
        $a.= buildTopNav (absolutepathfull."view/news","News","_self","News");
        $a.= buildTopNav (absolutepathfull."view/events","Events","_self","Events");
        $a.= buildTopNav (absolutepathfull."view/outputs","Outputs","_self","Outputs");
        $a.= "</tr></table>";
        return $a;
    }

    Now you'll only have to change one line of HTML-Code to customize the Top-Level-Navigation.

    Sorry, I am too tired for writing a complete instruction of the changes - but I guess you'll find it pretty easy to understand (at least I hope).

    Best regards,
    NC

     
    • Niels Christian

      Niels Christian - 2004-12-02

      Damn...

      Missed a $ in the line
      $a.= buildTopNav (absolutepathfull,"Home","_self","Home");

      - it must be
      $a.= buildTopNav ($absolutepathfull,"Home","_self","Home");

       

Log in to post a comment.