Tuesday, July 13, 2010 10:56:46 PM
multi-language, umbraco
It's a very flexible way to do multi-languages in Umbraco but it's not a 1-on-1 relation. So i could have pages that exist for example in the English version of my site, but not in the French version. This said, let's start.
First, let's create some more languages! Go to the settings section of your Umbraco installation. Right click on "Languages" and hit "create", add the languages you would like to use in your multi-language site. I added "French (Belgium)" and "Dutch (Belgium)" on top of the "English (United States)".
Second, go to the Content section and create nodes in the root of your site. I created 3, 1 for my Dutch site "NL", 1 for the French names "FR" and 1 for the English one "EN".
Next, right click a node and hit "manage hostnames" (it can be a fake one...) f.e. i added dummy.be and choose "Dutch (Belgium)" for my "NL" node. Now do the same for the other ones...
!! If you are doing like me and adding the nodes in the root of your site and adding fake hostnames you should disable "hidetoplevelnodefrompath" in the web.config, just saying

Now off you go, in the templates attached to your document types you can now use dictionary items to add content that is not likely to change often, all other content you can just grab off of the current document.
What'll not work out of the box with this approach is f.e. when you're on the Dutch version of a page and want to change languages but stay on the same page. You can however make a nice solution for this with the relationship API, more info
here
Saturday, February 13, 2010 5:16:02 PM
.net, xslt, umbraco, refresh
...
Situation:
- i have a .net usercontrol with updatepanel (login control, so i login, and the control says 'Welcome Gerty')
- i have an xslt macro in umbraco, which lists the navigation
Problem:
when i login i want the profile page to appear in the navigation.
Options:
- (cfr Neehouse) put navigation on an alttemplate and (re)load content in a div with jquery (this was not an option for us since we already use alttemplates and thus in certain places should be having alttemplates on alttemplates which would give problems)
- make the macro refresh........yes
How:
Well, i'll start by saying i think it's a crap way of doing it. But i currently have no idea on how to 'solve' it in a decent way. Suggestions are very welcome! And i don't know if it'll work on slow internet connections...still to test...
<script runat="server" type="text/C#">
protected void Page_Load(object sender, EventArgs e)
{
string javascriptCode = @"function test(){var hiddenFieldID = '" + HiddenField2.ClientID + "';var hiddenField = $get(hiddenFieldID);if (hiddenField) { if( hiddenField.value != new Date().getSeconds()){ hiddenField.value = (new Date()).getSeconds(); __doPostBack(hiddenFieldID,'');}}}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SomeKey", javascriptCode, true);
ScriptManager sm = ScriptManager.GetCurrent(Page);
if (sm.IsInAsyncPostBack)
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"anotherKey","test();",true);
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "anotherKey", "Sys.Application.add_load(test);", true);
}
}
</script>
------
<asp:UpdatePanel ID="pnlMainNav" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False">
<ContentTemplate>
<umbraco:Macro Alias="ListMainNavigation" runat="server"></umbraco:Macro>
<asp:HiddenField ID="HiddenField2" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="HiddenField2" EventName="ValueChanged" />
</Triggers>
</asp:UpdatePanel>
------
So what this will do is when i do something in my .net usercontrol it'll call the javascript function 'test' which will then update the contents of the hiddenfield in the updatepanel where my xslt macro stands and do a postback which will trigger the updatepanel of my xslt macro to refresh.
The crappy part of this whole chabbang is that when i don't add a check in it they will constantly refresh each other... resulting thus in an endless loop... therefor i added a check in the javascript and if the value (seconds of time) in the hiddenfield is the same as it is now it'll end....
So conclusion it is dirty but it works ( ! not tested on slow speed connections)
And if anyone has a better solution or improvement suggestions, please let me know