Editing Host File - Custom DNS

Sometimes we have clients who need to create content before their websites are live.  Okay, that is always a need.  

So, having them use a host file hack is the cleanest way for us to get sites setup, but not have to remember any odd links or amazon ec2 subdomains etc.

Custom Domain Pointer for your local machine:

These instructions require that you have administrator rights on your machine.

  1. Start - Run - Notepad (Hold "Shift" and Right Click on Notepad, choose "run as administrator") 
  2. File - Open
  3. Navigate to "C:\Windows\System32\drivers\etc"
  4. Open "Hosts"
  5. At the end of the file, on a new line enter "xx.xx.xx.xx  DomainName.Com"  where xx.xx.xx.xx is the IP address of the new site setup and DomainName.Com is the new site domain that is not setup yet.
  6. Save the File.
  7. Go to your browser and type in DomainName.Com
      

Background Image Flicker

Recently I noticed site flicker...  Okay, recently one of my co-workers noticed site flicker...  Fine, months ago, a co-worker noticed site flicker and I ignored the problem.  

I should mention the solution to this problem is mind bending.  W3C standards for CSS3 specify that backgrounds should go on the body tag.  However, I can't argue with the simple fact... that in practice, this works.

Description: When clicking links within a site, the background tends to flicker on reload.  This occurs even if the page structure is nearly identical.

Solution: Apply height/width/background to html tag instead of body tag.


html {
height: 100%;
width: 100%;
background: transparent url(image.png); }

Reference: W3C CSS3 Background Standards (unfinished) Problem with background color and google chrome

Ektron cms400net 801 multi-lingual not falling over to default language

We recently upgraded our Ektron CMS400.NET 7.66 SP4 site to 8.01.  Everything went smoothly except one thing: The foreign language sites started failing.  We had used a fall-over method for our translated sites.  For example, if the german site was loaded, and german translated content wasn't found, it would fall over to the english content.   This kept us from having to keep everything translated, and kept the site cleaner.

After about a week of back and forth with technical support, I got this email back:

 Hi Ben, 
I've spoken to my tech lead and it turns out you are seeing the expected results, in the current version of the CMS. Previously, the aliasing for different languages worked the way we discussed on the phone, where if the content did not exist in the current site language, the user would see the English content.

This was changed along the line because it takes the user out of the "language experience" so to speak - if you are viewing the site in French, and click on a link, the content should always be in French. If that content doesn't exist in French, then you'll get the 404.

I suspect that something is cached when you hit the page for the first time, but every time after, the aliasing is working as expected.

To avoid seeing the 404 errors, you would need to create the content in each language. One option, if you are not actually translating the content but would want users in other languages to see English content, would be to create a content strategy which would create the other-language content in the workarea upon creating/publishing the English version.

I hope that explanation makes sense, and I apologize for the confusion! Please let me know if you have any questions, or need any additional information.

I was actually relieved, because then I knew something wasn't broken.  So all I needed to do was "fix" the aliasing module to do what we wanted. Hope that it is clear... if the current language isn't found, we manually set to 1033 (english) and try the lookup again.  Hope this helps anyone in the same boat.

So now we are running fine again. If anyone is interested in how we are setting the languages.... I included that below as well.

Here is the updated UrlAliasingBase.cs


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for UrlAliasingBase
/// </summary>
public class UrlAliasingBase
{
    public static void ProcessUrl(HttpContext context)
    {

        //Check if this is a Asset request
        if (Ektron.ASM.EkHttpDavHandler.Utilities.IsAssetFile(context) || Ektron.ASM.EkHttpDavHandler.Utilities.IsPrivateAssetFile(context) || Ektron.ASM.EkHttpDavHandler.Utilities.IsDavFile(context))
    {
         return;
        }
        
        //Skip workarea files
        if (Ektron.Cms.UrlAliasing.UrlAliasCommonApi.IsWorkAreaFile(context))
    {
        return;
        }

        string fileExtension = string.Empty;
        fileExtension = System.IO.Path.GetExtension(HttpContext.Current.Request.PhysicalPath);

        if (fileExtension == string.Empty && !context.Request.Url.LocalPath.EndsWith("/"))
        {
            context.Response.Redirect(context.Request.Url.LocalPath + "/", true);
        }
        else
        {
            string targetUrl = Ektron.Cms.UrlAliasing.UrlAliasCommonApi.GetTargetUrl(context);

            // Ben Longberg
            // 1/28/2011
            // HACK - Ektron no longer supports failing over to english content when translated content does not exist.  (So this 'fixes' that)
            // Ektron Blows.
            //if empty check for english version
            if (string.IsNullOrEmpty(targetUrl))
            {
                HttpCookie ecm = context.Request.Cookies["ecm"];
                
                if (ecm != null && !string.IsNullOrEmpty(ecm["SiteLanguage"]))
                   {
                       ecm.Values.Remove("SiteLanguage");
                       ecm["SiteLanguage"] = "1033";
                       context.Response.Cookies.Add(ecm);
                   }

                targetUrl = Ektron.Cms.UrlAliasing.UrlAliasCommonApi.GetTargetUrl(context);
            }
            // END HACK

            if (!string.IsNullOrEmpty(targetUrl))
            {
                HttpContext.Current.Items["EkOriginalPath"] = HttpContext.Current.Request.Path; 
                context.RewritePath(targetUrl, false);
            }
        }
        
    }
}

public static void InitializeCulture(HttpContext context)
        {
            string host = context.Request.Url.Host;

            string appSettingKey = "language-" + host.ToLower();
            string langType = AppSettingsUtility.GetKeyValue(appSettingKey, "-1");

            HttpCookie ecm = context.Request.Cookies["ecm"];

            if (!String.IsNullOrEmpty(context.Request.QueryString["LangType"]))
            {
                langType = context.Request.QueryString["LangType"];
            }
            else
            {
                if (langType != "-1")
                {
                    if (ecm != null && !string.IsNullOrEmpty(ecm["SiteLanguage"]))
                    {
                        string currentLangType = ecm["SiteLanguage"];
                        if (currentLangType != langType)
                        {
                            ecm.Values.Remove("SiteLanguage");
                            ecm["SiteLanguage"] = langType;
                            context.Response.Cookies.Add(ecm);
                        }
                        //adding
                        //string currentLangType = ecm["langvalue"];
                        //if (currentLangType != langType)
                        //{
                        //    ecm.Values.Remove("langvalue");
                            ecm["langvalue"] = langType;
                            context.Response.Cookies.Add(ecm);
                        //}
                    }
                }
            }


            if (langType.Length > 0 && langType != "-1")
            {
                int lang = Convert.ToInt32(langType);

                Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);
                Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
            }
        }