Michael (masterslacker) wrote in component_help,
Michael
masterslacker
component_help

Recreating/Restoring the Navigation Bar

Have you used a tutorial that makes you override the page_layout() function and hence have lost the ability to have your Navigation Bar? That includes the Graphics Above Entries, Components on Both Sides and Scrolling Entries Section tutorials? Then here's some code that you can incorporate into your page_layout() function to recreate the Navigation Bar along the top including Previous and Next links for the various pages.

The code I've given below is a complete page_layout() function which I've taken primarily from the Graphics Above Entries tutorial and added in the code responsible for printing the navigation bar, which can be seen in blue. To recreate the navigation bar in your own function, you only need to copy the blue section of the code and place it after the <body> tag as seen in the tutorial.

If you're getting compile problems on the if statement line, remember that you need to close the html output before it by placing a """; after the <body> tag as shown. You might also need to reopen html output by placing a """ directly after the blue code as shown in front the <div> tag.

function page_layout(Page p) {

  # Start the html document and print the head section which controls the page title, stylesheet information,
  # server supplied head content, and custom header informtion from the print_custom_head function.
  var string title = $p->title();
  """
  <html>
  <head>
    <link rel="stylesheet" href="$p.stylesheet_url" type="text/css"/>
    $p.head_content
    """; $p->print_custom_head(); """
    <title>$title</title>
  </head>
  """;
  
  # Start the body section of the html document which controls the visible parts of the page.
  """<body>""";

  # Print the navigation bar if it is needed. This can be incorporated into any other tutorials which override
  # the page_layout() function, and should be placed immediately after the <body> tag above.
  if (not $*comp_navbar or $*comp_state=="none") {
    """
    <div class="header">
    """;
    print "<span class=\"header-item\"><a href=\""+$p.view_url{"recent"}+"\">$*nav_entries_text</a></span>";
    print "<span class=\"header-item\"><a href=\""+$p.view_url{"friends"}+"\">$*nav_friends_text</a></span>";
    print "<span class=\"header-item\"><a href=\""+$p.view_url{"archive"}+"\">$*nav_calendar_text</a></span>";
    print "<span class=\"header-item\"><a href=\""+$p.view_url{"userinfo"}+"\">$*nav_info_text</a></span>";
    if ($p.journal.website_url != "") {
        print "<span class=\"header-item\"><a href=\"$p.journal.website_url\">$p.journal.website_name</a></span>";
    }
    $p->lay_viewspec_nav();  # prints previous / next links including arrow images
    """	
    </div>
    """;
  }

  # Print a spacer at the top of the page above the components and main area.
  """<div><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="3" alt="" border="0"></div>""";

  # Start the table which lays out the components and main area in side-by-side layout.
  """
  <table width="100%" cellspacing="0" cellpadding="0" valign="top">
    <tr valign="top" width="100%">
      <td width="3">
        <img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="1" alt="" border="0">
      </td>
  """;
  
  # If the components are supposed to be on the left side of the page, then print them, followed by a column
  # with a spacer which is to seperate the components and the main area.
  if ($*comp_state == "left") {
    print_my_components($p);
    """
    <td width="3">
     <img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="1" alt="" border="0">
    </td>
    """;
  }

  # Print the main area of the page.
  print_my_entries($p, $title);

  # If the components are supposed to be on the right side of the page, then first print a column with a spacer 
  # and then print the components after the spacer. 
  if ($*comp_state == "right") {
    """
    <td width="3">
     <img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="1" alt="" border="0">
    </td>
    """;
    print_my_components($p);
  }

  # Finish off the table for the body
  """
      <td width="3">
        <img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="1" alt="" border="0">
      </td>
    </tr>
  </table>
  """;

  # End the body section and end the html document
  """
  </body>
  </html>
  """;
}
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 30 comments
Previous
← Ctrl ← Alt
Next
Ctrl → Alt →
Previous
← Ctrl ← Alt
Next
Ctrl → Alt →