2

How do you edit the HTML tag in a Kentico CMS Masterpage, i.e. to add a class attribute?

Currently I have this:

Kentico masterpage html tag

But I want:

<!DOCTYPE html>
<html class="myClass">
  <head>
    <title>

From the screenshot you can see that the HTML tag is not editable.

Is there a way to edit the html tag or tell Kentico to write a class attribute to the html tag?

4

3 回答 3

1

您还可以在页面模板上使用“Head HTML”Web 部件。

于 2012-05-29T22:35:01.297 回答
1

我找到了一种解决方案:

我在这个文件的 HTML 标记中手动添加了一个类属性:-

<solution>/CMSPages/PortalTemplate.aspx

于 2012-05-29T11:42:33.250 回答
1

令人失望的是,Kentico 仍然不支持开箱即用。<html>已提交能够直接从代码修改标签的请求:http: //ideas.kentico.com/forums/239189-kentico-product-ideas/suggestions/5947264-ability-to-modify-page-head- section-and-html-tag 同时使用以下解决方案:

门户引擎

根据Dave Haigh的建议,我通过以下方式解决了这个问题。在文件中/CMSPages/PortalTemplate.aspx更改以下行:

<html xmlns="http://www.w3.org/1999/xhtml" <%=XmlNamespace%>
    lang="<%=CMSContext.PreferredCultureCode%>">

ASPX 引擎

在您的母版页中,将以下代码段添加到您的代码隐藏文件中:

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
    if (CurrentDocument != null)
    {          
        CMS.UIControls.ContentPage page= this.Page as CMS.UIControls.ContentPage;
        if (page != null)
        {
            string lang= CMS.Localization.LocalizationContext.CurrentCulture.CultureCode;
            page.XmlNamespace += " lang=\"" + lang + "\"";
        }
    }
}
</script>

来源:http ://devnet.kentico.com/questions/kentico-9-how-to-define-language-in-html

于 2016-12-22T17:46:35.920 回答