How can I modify on server side browser language detection

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/11/2010 2:44:56 AM
Gravatar
Total Posts 98

How can I modify on server side browser language detection

Hello Joe,

  I want to detect the browser language for redirect my site to specific interface.

  I put this section:

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack && Session["lang"] == null)
{
string[] languages = Request.UserLanguages;
string lang = languages[0].Substring(0,2);
if (lang=="es" || lang=="fr" || lang=="de")
{
Session["lang"] = lang;
if (lang == "es")
Response.Redirect("sp");
else
Response.Redirect(lang);
}
}
}
</script>

on layout.Master from path wwwroot\Data\Sites\1\skins\skinbyVali

 

This code works ok but my layout is broken for site 1

How can I put this code behind? Where i should write this?

I have on site 1 already some custom modules created with codesmith and postbuild..

 


Thanks,

   Valik

1/11/2010 5:50:55 AM
Gravatar
Total Posts 18439

Re: How can I modify on server side browser language detection

You should not put code directly in the layout.master file. Instead, encapsulate your logic in a UserControl and then add the UserControl to your layout.master.

Hope it helps,

Joe

1/11/2010 6:25:37 AM
Gravatar
Total Posts 98

Re: How can I modify on server side browser language detection

I understand..

I try to modify from source code my layout.Master.cs page but no effect...

(maybe because is not the layout.Master which exist in site 1)

 

Thanks

1/11/2010 6:32:13 AM
Gravatar
Total Posts 18439

Re: How can I modify on server side browser language detection

You should not modify the mojoPortal source code at all, if you upgrade you will lose changes.

The site uses the layout.master file from the skin folder at /Data/Sites/[SiteID]/skins/[skinname]/layout.Master

However the layout.Master file in every included skin inherits from App_MasterPages/layout.Master.cs

This code behind handles assigning css classes to the divCenter based on whether each of the panels has any content or menus in it, so it facilitates automatic column layout from 1 to 3 columns.

Nothing stops you from making a new layout.Master that inherits from your own code behind file but then you lose the built in column layout feature.

Best to just create a custom UserControl and declare it in the layout.master file of your skin without touching the C# code in layout.Master.cs.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.