Content Rendering Languages
To add language support in a content renderer you have to supply a language attribute on theOptiWebRequestobject. The content render must be adapted to add language support.
-
Define a string to hold language
StringstrLang =null;
-
Get Language from URL
if(""+ Request.QueryString["LANG"] !="")
{
strLang =""+ Request.QueryString["LANG"];
} -
Check session if language is present
elseif(""+ Session["lang"] !="")
{
strLang =""+ Session["lang"];
} -
Set the default language
if(String.IsNullOrEmpty(strLang))
{
strLang ="EN";
} -
Add language to session and set language on the object OptiWebRequest
Session["lang"] = strLang;
Request.Attributes["REQUEST.LANGUAGE"] = strLang; -
Set the language in the Editor section on mails, pages and sections.You can choose what language a page, mail or section is, by just clicking on the properties and selecting thelanguage.
The result of the content renderer page with language handling looks like following:
<%@PageTitle="Home Page"Language="C#"AutoEventWireup="true"%>
<%@ImportNamespace="System"%>
<%@ImportNamespace="System.Configuration"%>
<%@ImportNamespace="MessagentNET"%>
<scriptrunat="server">
StringincHead, incBody, incBodyAttr;
protectedvoidPage_Load(objectsender,EventArgse)
{
if(""+ Request.QueryString["ID"] !="")
{
OptiWebRequestiRequest =newOptiWebRequest(this);
iRequest.CollectDebugInfo =false;
iRequest.AutoRedirect =false;
iRequest.MessagentUrl ="http://formations.emsecure.net/optiext/optiextension.dll";
foreach(stringvarinRequest.QueryString)
{
iRequest.Attributes[var] = Request.QueryString[var];
}
foreach(stringvarinRequest.Form.AllKeys)
{
iRequest.Attributes[var] = Request.Form[var];
}
// LANGUAGE
StringstrLang =null;
if(""+ Request.QueryString["LANG"] !="")
{
strLang =""+ Request.QueryString["LANG"];
}
elseif(""+ Session["lang"] !="")
{
strLang =""+ Session["lang"];
}
if(String.IsNullOrEmpty(strLang))
{
strLang ="EN";
}
Session["lang"] = strLang;
iRequest.Attributes["REQUEST.LANGUAGE"] = strLang;
OptiWebResultm_WebResult = iRequest.Send();
incHead = m_WebResult.HtmlHead;
if(m_WebResult.ResultType ==OptiWebResult.OptiWebResultType.Redirect)
incBody ="<script language=\"javascript\" type=\"text/javascript\">\n\tdocument.location = \""+ m_WebResult.Url +"\";\n</scr"+"ipt>";
else
incBody = m_WebResult.HtmlBody;
incBodyAttr =" "+ m_WebResult.HtmlBodyAttr;
}
else
{
incHead ="";
incBody ="Error - No ID provided";
incBodyAttr ="";
}
}
</script>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en">
<headid="Head1"runat="server">
<linkhref="~/Styles/Site.css"rel="stylesheet"type="text/css"/>
<%=incHead%>
</head>
<body<%=incBodyAttr%>>
<!-- put header/navigation here -->
<%=incBody%>
<!-- put footer/navigation here -->
</body>
</html>