jana: [Naruto] Sakura (Default)
Jana ([personal profile] jana) wrote in [community profile] style_system2010-11-07 01:05 pm

[SOLVED] Nav links in transmogrified

I know you can hide links from the navigation link bar with css, but how can you actually remove a link (in the theme layer)? I'd like to replace a link with a link to an external website, so my second question is how you can add a(n external) link to your nav links. Any help is much appreciated.
ninetydegrees: Art & Text: heart with aroace colors, "you are loved" (Default)

[personal profile] ninetydegrees 2010-11-07 01:44 pm (UTC)(link)
I've always used S2 code to do it:

function print_module_navlinks() {

  var Page p = get_page();
  var string[] navlinks_order = [];
  var string{} navlinks_urls = {};
  var string{} navlinks_text = {};

  $navlinks_order =
    [
        "recent",
        "archive",
        "read",
        "network",
        "tags",
        "memories",
        "custom1",
        "custom2",
        "userinfo",
    ];

 $navlinks_urls =
    {
        "recent" => "$p.base_url/",
        "archive" => "$p.base_url/calendar",
        "read" => "$p.base_url/read",
        "network" => "$p.base_url/network",
        "tags" => "$p.base_url/tag",
        "memories" => "$*SITEROOT/tools/memories?user=$p.journal.username",
        "custom1" => "http://URL",
        "custom2" => "http://URL",
        "userinfo" => "$p.base_url/profile",
    };

 $navlinks_text =
    {
        "recent" => "$*text_view_recent",
        "archive" => "$*text_view_archive",
        "read" => "$*text_view_friends",
        "network" => "$*text_view_network",
        "tags" => "$*text_view_tags",
        "archive" => "$*text_view_memories",
        "custom1" => "Custom Text",
        "custom2" => "Custom Text",
        "userinfo" => "$*text_view_userinfo",
    };

    open_module("navlinks", "", "");
    var string[] links = [];
    foreach var string k ($navlinks_order) {
        if ($navlinks_urls{$k} != "") {
            var string css = """ class="$k" """;
            if ($p.view == $k) { $css = """ class="current $k" """; }
            $links[size $links] = """<a href="$navlinks_urls{$k}"$css>$navlinks_text{$k}</a>""";
        }
    }
    print_module_list($links);
    close_module();
}


Note: this is template code for paid, personal accounts.
Edited 2010-11-07 13:45 (UTC)
foxfirefey: Look at this wee octopus! LOOK AT IT! (squee)

[personal profile] foxfirefey 2010-11-07 07:08 pm (UTC)(link)
Ooooh can I take this code and make an article for it in the S2 Cookbook?
ninetydegrees: Art & Text: heart with aroace colors, "you are loved" (Default)

[personal profile] ninetydegrees 2010-11-07 07:11 pm (UTC)(link)
Sure! If I'm not mistaken, non-paid and communities shouldn't add the network link and communities should use text_view_friends_comm for the read link text.

And of course, this code is also useful to re-order links and remove ones. You know who taught me that (and by that I mean arrays)? Kunzite. Good ole days...
Edited 2010-11-07 19:13 (UTC)
foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)

[personal profile] foxfirefey 2010-11-08 07:28 pm (UTC)(link)
Tada! Your advice is the first entry in the modules section of the Cookbook.

Aw, Kunzite! He's doing pretty good nowadays last I heard from him, just doesn't do style stuff anymore.