If you could add something to Kentico, what would it be and why?

body class

Need way to add custom class names to body tag.

Customizing via CMSContext.CurrentBodyClass isn't sufficient -- it's clumsy and subject to deprecation.

23 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
Craig shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Mark Handy commented  ·   ·  Flag as inappropriate

    I needed a custom class so i could identify the page. I put this together. I'm running an ASPX/Portal build.

    // we grab the alias path from Kentico, and trim the leading forward slash
    string aliasPath = CMS.DocumentEngine.DocumentContext.OriginalAliasPath.ToLower().TrimStart('/');

    if (aliasPath == "")
    {
    this.BodyClass += " homePage";

    }
    else
    {
    this.BodyClass += " " + aliasPath.Replace("/", "--");
    }

  • Dmitri commented  ·   ·  Flag as inappropriate

    our support made a custom web part named "Add Body Class". Very widely used indeed

Feedback and Knowledge Base