Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Armitage 505 posts 2073 karma points
    Feb 25, 2016 @ 07:04
    David Armitage
    0

    Dictionality translatings not loading when logged into the backend

    Hi,

    There seems to be a strange bug on my Umbraco site. I have got multiple languages loading the translations from the dictionary as standard. They are working fine and as expected. (Apart from this strange error)

    When I log into the Umbraco backend (content editor) it seems to then prevent the dictionary items from loading (like they don't exist)

    If I then logout of the CMS they load fine again and the translations in the front end of the site are fine.

    I have tested this a number of times on different browsers and different machines and I can re-create everytime (it's defiantly related to the backend login somehow). I also tested on localhost and again exactly the same issue.

    My guess is some language cookies are been set which is confusing things?

    Has anyone else experienced this and got a fix? I must say this seems like something recent as I cant say I have noticed it in the last and I am always working on both the back and front end at the same time.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Feb 25, 2016 @ 10:52
    Dave Woestenborghs
    0

    Hi David,

    Where are the dictionairy items not loading ? Do you mean under Settings > Dictionairy ?

    Dave

  • David Armitage 505 posts 2073 karma points
    Feb 25, 2016 @ 11:00
    David Armitage
    0

    Hi,

    They are loading fine in the backend tree but the issue is pulling them through to the front end using the umbracohelper.

    Like I said though if you are logged out of the umbrco backend the dictionary items pull through fine. It's only when you are logged in that the umbracohelper returns a null for each dictionary item.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Feb 25, 2016 @ 11:42
    Dave Woestenborghs
    0

    Strange. What Umbraco version are you using ?

    Dave

  • David Armitage 505 posts 2073 karma points
    Feb 26, 2016 @ 08:19
    David Armitage
    0

    Hi Dave,

    Here is some extra information...

    1. Umbraco Version 7.1.8 assembly: 1.0.5394.16131

    2. This does not seem to be related to every page. Here is an example of the page which encounters the error when logged into the back end https://www.expatjobzth.com/job/technical-support-consultant/bangkok-other/5713

      • This is related to every page using this template
    3. I tested logging in as a member rather than a backend user. The error doesn't exist - great my end users wont see the issue :). It seems it just related to been logged into the backend.

    4. Here is an example how I retrieve the dictionary items var umbracoHelper = new Umbraco.Web.UmbracoHelper(); @umbracoHelper.GetDictionaryValue("Job Description")

    5. I cant see anything particularly different from this template to the rest but here is an example of the code. Maybe you can spot something.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using CMS @using CMS.Models @using CMS.Utils @using umbraco.NodeFactory @using Umbraco.Web.Models @using umbraco.cms.businesslogic.web

    @{ Layout = "MasterView.cshtml";

    JobSettings jobSettings = new JobSettings();
    var homepageNode = ContentManager.GetCurrentHomepage();
    var umbracoHelper = new Umbraco.Web.UmbracoHelper();
    var language = ContentManager.GetLanguageByNode(homepageNode);
    var urlSegments = (string[])TempData["urlSegments"];
    var currentMember = MemberManager.GetCurrentMemberProfile();
    
    string currentMemberId = currentMember != null ? currentMember.UmbracoMemberId.ToString() : string.Empty;
    string currentMemberType = currentMember != null ? currentMember.MemberType : string.Empty;
    
    if (TempData["JobSearch"] != null)
    {
        TempData["JobSearch"] = TempData["JobSearch"];//resets the temp data for the back to search results button
    }
    
    int jobId;
    if (int.TryParse(urlSegments[urlSegments.Count() - 1], out jobId) == false)
    {
        Response.Redirect(homepageNode.NiceUrl.TrimEnd('/') + "/page-not-found");
        return;
    }
    
    Job job = JobManager.GetJobById(jobId);
    
    if (job == null)
    {
        Response.Redirect(homepageNode.NiceUrl.TrimEnd('/') + "/page-not-found");
        return;
    }
    else
    {
        //update job views
        JobManager.UpdateJobPurchaseViews(job.Id);
    
        if (!JobManager.IsJobActive(job))
        {
            Response.Redirect(homepageNode.NiceUrl.TrimEnd('/') + "/job-inactive");
            return;
        }
    
        TempData["pageTitle"] = JobManager.GenerateJobMetaTitle(job, Umbraco.Field("pageTitle").ToString(), language.CultureAlias);
        TempData["pageDescription"] = JobManager.GenerateJobMetaDescription(job, Umbraco.Field("pageDescription").ToString(), language.CultureAlias);
    
        //this handles the canonical url
        if (job.EmploymentType != null && (job.EmploymentType.Id == 2660 || job.EmploymentType.Id == 2662))
        {
            if (language.CultureAlias == "en-US")
            {
                if (homepageNode.Id != 1751)
                {
                    Node expatUS = ContentManager.GetNodeById(1751);
                    var canonicalUrl = expatUS.NiceUrl.Trim('/') + JobManager.GenerateJobUrl(job);
                    TempData["canonicalUrl"] = canonicalUrl;
                }
            }
            else if (language.CultureAlias == "th-TH")
            {
                if (homepageNode.Id != 2245)
                {
                    Node expatTH = ContentManager.GetNodeById(2245);
                    var canonicalUrl = expatTH.NiceUrl.Trim('/') + JobManager.GenerateJobUrl(job);
                    TempData["canonicalUrl"] = canonicalUrl;
                }
            }
        }
    
        <div class="inner-banner">
            <div class="container">
                <div class="row">
                    <div class="col-md-6">
                        <h1>@umbracoHelper.GetDictionaryValue("Job Description")</h1>
                    </div>
                    <div class="col-md-6"></div>
                </div>
            </div>
        </div>
    
        <div class="content">
            <div class="container">
    
                <div class="job">
                    <h2>
                        @JobManager.GetJobTitleLocalised(job, language.CultureAlias)
                    </h2>
                    <div class="row">
                        <div class="col-md-9">
                            <h3>@job.ListedDate.ToLongDateString()</h3>
                            <ul>
                                <li>@Umbraco.GetDictionaryValue("Reference"): @JobManager.GenerateJobReference(job.Id)</li>
                                <li>@Umbraco.GetDictionaryValue("Industry"): @umbracoHelper.GetDictionaryValue(job.Industry.Name) (@umbracoHelper.GetDictionaryValue(job.SubIndustry.Name))</li>
                                <li>@Umbraco.GetDictionaryValue("Location"): @Umbraco.GetDictionaryValue(job.Location.Name) (@Umbraco.GetDictionaryValue(job.SubLocation.Name))</li>
                                <li>@Umbraco.GetDictionaryValue("Work Type"): @Umbraco.GetDictionaryValue(job.WorkType.Name)</li>
                                <li>@umbracoHelper.GetDictionaryValue(job.EmploymentType.Name)</li>
                            </ul>
                        </div>
                        <div class="col-md-3 listing-logo desktop">
                            @if (!string.IsNullOrEmpty(JobManager.GenerateJobLogoUrl(job)))
                            {
                                <div class="listing-image">
                                    <img src="@JobManager.GenerateJobLogoUrl(job)?width=140&height=85&mode=crop" alt="Company Logo" />
                                </div>
                            }
                        </div>
                    </div>
                    <div class="job-description">
                        <h3>@umbracoHelper.GetDictionaryValue("Job Description"):</h3>
                        @Html.Raw(JobManager.GetJobDescriptionLocalised(job, language.CultureAlias))
                    </div>
    
                    <div class="captcha">
                        <div class="row">
                            <div class="col-md-3">
                                <a class="btn btn-search alternate mobile" href="@(homepageNode.NiceUrl.TrimEnd('/') + "/jobs")">@umbracoHelper.GetDictionaryValue("Back to Job Listings")</a>
                                <a class="btn btn-search alternate desktop" href="@(homepageNode.NiceUrl.TrimEnd('/') + "/jobs")">@umbracoHelper.GetDictionaryValue("Back to Job Listings")</a>
                            </div>
                            <div class="col-md-3 submit">
                                <a id="btnApply" class="btn btn-search desktop">@umbracoHelper.GetDictionaryValue("Apply Now")</a>
                                <a href="@homepageNode.NiceUrl.TrimEnd('/')@JobManager.GenerateJobApplicationUrl(job)" target="_blank" class="btn btn-search mobile">@umbracoHelper.GetDictionaryValue("Apply Now")</a>
                            </div>
                            <div class="col-md-1">
                                <img id="apply-ajax-loader" style="display:none;" src="~/Frontend/Images/ajax-loader.gif" />
                            </div>
                            <div class="col-md-5 social-media">
                                <span>@umbracoHelper.GetDictionaryValue("Share on Social Media")</span><br/>
                                <div class="addthis_sharing_toolbox"></div>
                            </div>
                        </div>
                    </div>
    
                    <div class="message-section row text-left">
                        <div id="apply-error-message" style="display:none;">
                            <!--error message is populated through the json result-->
                        </div>
                        <div id="apply-success-message" style="display:none;">
                            <h3>@umbracoHelper.GetDictionaryValue("Thank you for submitting an application")</h3>
                        </div>
                        <div id="apply-wrong-user-type-message" style="display:none;">
                            <h3>@umbracoHelper.GetDictionaryValue("Please login or create a job seeker account to make applications")</h3>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    
    }
    

    }

    <script type="text/javascript" src="~/Frontend/Scripts/Libs/jQuery.print-master/jQuery.print.js"></script>
    <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5507cd9f59a586d7" async="async"></script>
    <script type="text/javascript" src="~/Frontend/Scripts/Libs/Fancybox/source/jquery.fancybox.js?v =2.1.5"></script>

    <script type="text/javascript">
        $(document).ready(function () {
    
            $("#btnApply").click(function () {
    
                var currentMemberId = '@currentMemberId';
                var currentMemberType = '@currentMemberType';
                var applicationUrl = '@job.ApplicationUrl';
    
                if (currentMemberType == "JobSeeker" && applicationUrl == '') {
    
                    $.ajax({
                        url: '/umbraco/surface/FormsSurface/JobApplication?memberId=' + currentMemberId + '&[email protected]&[email protected]',
                        contentType: 'application/json; charset=utf-8',
                        type: 'POST',
                        dataType: 'json',
                        beforeSend: function () {
                            $('#apply-ajax-loader').show();
                            $('#btnApply').attr("disabled", true);
                        },
                        success: function (classifications) {
                            $('#apply-success-message').show();
                            $('#apply-ajax-loader').hide();
                            $('#btnApply').attr("disabled", false);
    
                            //load the iframe here
                            $('#frameGoogleConversion').attr('src', '/GoogleConversion.html?type=post-job');
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            $('#apply-ajax-loader').hide();
                            $('#btnApply').attr("disabled", false);
                        }
                    });
    
                }
                else if(currentMemberType == "Employer" || currentMemberType == "Agency")
                {
                    $('#apply-wrong-user-type-message').show();
                }
                else {
                    $.fancybox.open({
                        href: '@(!string.IsNullOrEmpty(job.ApplicationUrl) ? job.ApplicationUrl : homepageNode.NiceUrl.TrimEnd('/') + JobManager.GenerateJobApplicationUrl(job))',
                        type: 'iframe',
                        width: 650,
                        height   : "100%",
                        autoSize: false
                    });
                }
    
            });
    
        });
    </script>
  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Feb 26, 2016 @ 08:35
    Dave Woestenborghs
    0

    Hi David,

    I see you setup your own umbracoHelper object.

    In the template you can normally also access it using

    @Umbraco.GetDictionaryValue("Please login or create a job seeker account to make applications")
    

    Can you try using this and see if the problem still occurs ?

    Dave

  • David Armitage 505 posts 2073 karma points
    Mar 10, 2016 @ 03:52
    David Armitage
    0

    Hi,

    I tried what you said and this still didn't fix the problem.

    I have uploaded a zip file of all my views, macro partials, and partial files. Maybe this will help.

    It is very strange...

    1. The problem is only happening on the JobLandingPage view

    2. Pretty much most views are using @Umbraco.GetDictionaryValue but the JobListPage is similar and I can confirm this is also working fine.

    3. There is defiantly something relating to the JobLandingPage view but I just cant see what is different. Please let me know if you need any more files.

    4. Worst case I might be able to upload a test site and provide login details.

    Download the views here!

    Thanks

    David

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 10, 2016 @ 08:40
    Dave Woestenborghs
    0

    Hi David,

    hard to see without the entire code/db.

    can you tell me what the code of this call is ?

    var currentMember = MemberManager.GetCurrentMemberProfile();
    

    Dave

  • David Armitage 505 posts 2073 karma points
    Mar 10, 2016 @ 09:34
    David Armitage
    0

    Hi Dave,

    I will send the full source and data if you provide your email. I would prefer not to upload everything public.

    Thanks for your assistance.

    Kind Regards

    David

Please Sign in or register to post replies

Write your reply to:

Draft