Log in

No account? Create an account

Previous Entry | Next Entry

Adding links to header - SOLVED!

  • Apr. 24th, 2008 at 9:42 AM
Hi guys,
I've looked at navigation-link-related materials and I'm still not sure what I need to do. At the top of my page, I'd like to add more links to the navigation. So Recent Entries, Archive, Memories, __custom link__.

How do I do this?

Thanks! And sorry for the n00b question.


( 8 comments — Leave a comment )
Apr. 24th, 2008 03:08 pm (UTC)
Please don't post locked entries.

You'll need to create a custom theme layer and put the additional links into the Page::lay_print_header_links() function. There are tutorials here for creating the layer, but I won't be able to help with the other part for a couple of hours.
Apr. 24th, 2008 03:20 pm (UTC)
Sorry about that--the entry is now public. Thanks for your help. I look forward to reading more when you have time. Thanks!
Apr. 25th, 2008 01:15 pm (UTC)
Sorry to have kept you waiting. There was a code push last night and I wanted to make sure none of LJ's code changes would interfere. This code will go in the theme layer, if you're going through the previously-linked tutorial.
function Page::lay_print_header_links() {
    # Menu start
    """<div id="message-window" class="hidden"></div>\n""";
    """<div id="header-photo">\n<div id="header-photo-inner"></div>\n</div>\n""";
    """<div id="header-text"><ul class="nav">\n""";

    # Standard Journal Pages (Recent, Archive, Friends, Userinfo)
    foreach var string v ($.views_order) {
        var string url   = $.view_url{$v};
        var string text  = lang_viewname($v);
        var string class = "item";
        if($v == $.view) {
            $class = $class + " current";
        if($v == $.views_order[0]) {
            $class = $class + " first";

        $class = " class=\"$class\"";

        print """<li$class><a href="$url" title="$text">$text</a></li>""";

    var Link memories_url = $.journal->get_link("memories");

    # Memories
    if($memories_url.url != "") {
        println safe """<li class="item"><a href="$memories_url.url" title="$*text_view_memories">$*text_view_memories</a></li>""";

    # Additional links
    println safe """<li class="item"><a href="http://www.exampleurl.com/" title="Pop-up Text">Example Link</a></li>""";

    # Menu end
    <div id="header-name">""";
    var string base_url = $.journal->base_url();
    var string friends_url = $.view_url{"friends"};
    if ($this isa FriendsPage) {
        print safe """<a href="$friends_url">""" + $this->view_title() + """</a>""";
    } else {
        print safe """<a href="$base_url">$.global_title</a>""";

    if(not $this isa FriendsPage) {
        print safe """
      <div id="header-description">$.global_subtitle</div>""";

    </div><span id="header-content-decor" class="decor"><b></b><u></u><s></s><i></i></span></div><!-- End Header Content -->
    </div><span id="header-decor" class="decor"><b></b><u></u><s></s><i></i></span></div><!-- End Header -->""";
You can duplicate the highlighted line to add as many links as you want.
Apr. 25th, 2008 02:02 pm (UTC)
Thanks so much! This works well. I've got dummy links up at the moment, but now that I've got the css in place, I can tweak this over the weekend. Thanks again!
Apr. 25th, 2008 03:03 pm (UTC)
Re: Thanks!!
You're welcome. Would you mind also editing the post to add a title, something like "Adding links to header [Solved]"?
Jun. 11th, 2008 06:21 am (UTC)
I hate to make a new post about this since it's just a yes or no answer about your comment. Will taking out this part of the code hurt anything:

    var Link memories_url = $.journal->get_link("memories");

    # Memories
    if($memories_url.url != "") {
        println safe """<li class="item"><a href="$memories_url.url" title="$*text_view_memories">$*text_view_memories</a></li>""";

For some reason I was getting a huge gap in between my last normal navigation link and the custom one I was adding. When I took that part out it shot it back over where it was supposed to be. Is that okay or do I need those lines back in there?
Jun. 11th, 2008 12:56 pm (UTC)
You need it if you want the link to Memories in the top nav bar. ;) I can't think of any reason why having it would cause spacing problems, but I'd have to see it in action.

EDIT ... so, no, taking it out won't hurt anything, in case that wasn't clear.

Edited at 2008-06-11 12:57 pm (UTC)
Jun. 11th, 2008 11:06 pm (UTC)
Thanks! Yeah I have no idea why it was messing up with the spacing but it worked as soon as I took those lines out.
( 8 comments — Leave a comment )

Latest Month

March 2016

S2 Help Communities


Powered by LiveJournal.com
Designed by chasethestars