S2 Cookbook: Modules
From Dreamwidth Notes
Revision as of 06:01, 13 January 2011 by Ninetydegrees (Talk | contribs)
To override the order or content of the navigation module, override this function with the following (note the comments, some options should be removed or changed for unpaid accounts or communities).
# code by ninetydegrees 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", # remove this for unpaid journals "network", "tags", "memories", # remove these if you don't want to add custom links "custom1", "custom2", "userinfo", ]; $navlinks_urls = { "recent" => "$p.base_url/", "archive" => "$p.base_url/archive", "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", # use $*text_view_friends_comm for communities "read" => "$*text_view_friends", "network" => "$*text_view_network", "tags" => "$*text_view_tags", "memories" => "$*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(); }