How to move the localization list into the header/footer?

Topics: Core, Customizing Orchard, Localization, Writing themes
Apr 14, 2014 at 10:22 AM
I have a minimal theme set up for a multilingual website. As far as I can tell the list of links to translated versions of the current page is part of the content, so it can only be rendered inside the content area, correct?

However I need to place that list/links in a different part of the layout, like the header or the footer. How can I do this the "correct" way?

I have already found a "hacky" way to do this, I'm posting it here for reference:

If the Display(Model.Header) funktion os called in the Display.cshtml the localization link list is part of the long Model.Metadata.ChildContent string (with other things like the page title and the actual content text). I can "extract" the list like this in the Layout.cshtml
<div class="translations_list">
                            //Extrahiere die Localization links aus den Metadaten
                            var metaData = Model.Metadata.ChildContent;
                            string tempString = metaData.ToString();

                            String startTag = "<ul";
                            String endTag = "ul>";
                            int start = tempString.IndexOf(startTag);
                            int end = tempString.IndexOf(endTag);
                            String result = "";
                            if ((start >= 0) && (end >= 0))
                                result = tempString.Substring(start + startTag.Length, end - (start + startTag.Length));
                            var resultHtml = "<ul " + result + "ul>";
I can place this <div> with the list whereever I want, which is basically what I wanted.
However in order for the metadata to actually contain the string I want, I have to use the Display(Model.Header) function in the Content.cshtml to begin with. That means I have the same content (localization list, page title) in the content area again. It's double content or no content. So I hide the div in the content area like this:
<div class="content_header" style="display:none;">
This "solution" works, but I consider it to be very "hacky" and not in spirit with how Orchard Theming is supposed to work. There must be some elegant way to make the localization list (and ONLY the list) available to use in the Layout.cshtml without rendering the whole header content inside the content area again, correct?

I'd be very grateful if you could explain to me how this is/should be done.

(Please assume I'm very new to Orchard and MVC.)
May 1, 2014 at 10:26 PM
Use the file. Adding
<Place Parts_Localization_ContentTranslations="/Header:0"/>
will move the localization shape to the Header zone.