Copied to clipboard

Flag this post as spam?

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


  • ds 191 posts 223 karma points
    Jul 10, 2015 @ 20:52
    ds
    0

    Hi Dimitri,

    I have successfully installed and using your package under 7.2.1.

    I could not manage to fix an issue and hope that you can help.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    <div class="container gallery gallery__indent">
        <h3>@Umbraco.RenderMacro("PropertyTranslation", new {Property="pageTitle"})</h3>
        <ul>
            @foreach (var page in CurrentPage.Children.Where("Visible"))
            {
                <li>                    
                    <a href="@page.Url">
                        @Umbraco.RenderMacro("PropertyTranslation", new {Property="pageTitle"})
                    </a>
                </li>
            }
        </ul>
    </div>
    

    and I have also such structure enter image description here

    "Dönemler" nodes have 5 sub nodes but by looking at above codes PropertyTranslation between h3 works normally but within foreach loop I can not display any "pageTitle" property.

    With this code, I get above output. enter image description here

  • dimi309 245 posts 579 karma points
    Jul 11, 2015 @ 19:13
    dimi309
    0

    You probably need PropertyReferenceTranslation. It works just like PropertyTranslation but it also takes a node ID as parameter. Since these are subnodes, if I have understood correctly, you need to pass each subnode's ID to the macro.

  • ds 191 posts 223 karma points
    Jul 13, 2015 @ 19:10
    ds
    0

    Hi Dimitri,

    How can I pass that subnode's ID to the macro? Could you show me on that script which I supplied.

  • ds 191 posts 223 karma points
    Jul 15, 2015 @ 19:07
    ds
    0

    Hi Dimitri,

    I would be very appreciated if you could give any help.

  • dimi309 245 posts 579 karma points
    Jul 15, 2015 @ 19:41
    dimi309
    0

    It should be page.Id. See how I do it in my translated navigation menu:

    https://github.com/dimitrikourk/Polyglot/blob/v2/Dimi.Polyglot/UmbracoRazorScripts/TranslatedNavigation.cshtml

  • ds 191 posts 223 karma points
    Jul 15, 2015 @ 19:52
    ds
    0

    Hi again Dimitri,

    I am not so experienced :( Therefore after some try, I get Error loading MacroEngine script (file: PropertyReferenceTranslation.cshtml)

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    <div class="container gallery gallery__indent">
        <h3>@Umbraco.RenderMacro("PropertyTranslation", new {Property="pageTitle"})</h3>
        <ul>
            @foreach (var page in CurrentPage.Children.Where("Visible"))
            {
                @*<li class="grid_4">*@ 
                <li>                    
                    <a href="@page.Url">
                        @Umbraco.RenderMacro("PropertyReferenceTranslation", new {NodeID="@page.Id", Property="pageTitle"})
                    </a>
                </li>
            }
        </ul>
    </div>
    
  • dimi309 245 posts 579 karma points
    Jul 15, 2015 @ 20:10
    dimi309
    0

    Try this. Outside the loop, do:

    string selectedLanguage = RenderPage("SelectedLanguage.cshtml").ToString().Trim();

    Then, inside the loop:

    RenderPage("PropertyReferenceTranslation.cshtml", page.Id, "pageTitle", selectedLanguage).ToString();

    Let me know if it worked. I wrote it off the top of my head so I may have made a small mistake somewhere...

  • ds 191 posts 223 karma points
    Jul 15, 2015 @ 20:21
    ds
    0

    I have following code;

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    <div class="container gallery gallery__indent">
        <h3>@Umbraco.RenderMacro("PropertyTranslation", new {Property="pageTitle"})</h3>
    
        string selectedLanguage = RenderPage("SelectedLanguage.cshtml").ToString().Trim();
        <ul>
            @foreach (var page in CurrentPage.Children.Where("Visible"))
            {
                <li>                    
                    <a href="@page.Url">
                        RenderPage("PropertyReferenceTranslation.cshtml", page.Id, "pageTitle", selectedLanguage).ToString();
                    </a>
                </li>
            }
        </ul>
    </div>
    

    The result look like this; enter image description here

  • dimi309 245 posts 579 karma points
    Jul 15, 2015 @ 20:29
    dimi309
    0

    Ah, yes. Surround the selectedLanguage assignment by @{ string selectedLanguage .... } and put a @ in front of RenderPage.

  • ds 191 posts 223 karma points
    Jul 15, 2015 @ 20:40
    ds
    0

    This is what I have got

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    <div class="container gallery gallery__indent">
        <h3>@Umbraco.RenderMacro("PropertyTranslation", new {Property="pageTitle"})</h3>
    
        @{ string selectedLanguage = RenderPage("SelectedLanguage.cshtml").ToString().Trim(); }
        <ul>
            @foreach (var page in CurrentPage.Children.Where("Visible"))
            {
                <li>                    
                    <a href="@page.Url">
                        @RenderPage("PropertyReferenceTranslation.cshtml", page.Id, "pageTitle", selectedLanguage).ToString();
                    </a>
                </li>
            }
        </ul>
    </div>
    

    enter image description here

  • dimi309 245 posts 579 karma points
    Jul 15, 2015 @ 20:51
    dimi309
    0

    Sorry... I may have made a mistake. Try it the way you originally did it, only using:

    @Umbraco.RenderMacro("PropertyReferenceTranslation", new {NodeID=page.Id, Property="pageTitle"})

    delete the selectedLanguage parts. I'm sorry for trying things out like this right now but I am sitting behing a mac and I cannot test...

  • ds 191 posts 223 karma points
    Jul 15, 2015 @ 21:06
    ds
    0

    That made it work, Dimitri. I have also realized something. After changing the subnodes into English, if you would click translated link, it turns back to original language.

    I do not know whether it is my fault doing something wrong or some gap in your package?

  • dimi309 245 posts 579 karma points
    Jul 15, 2015 @ 21:46
    dimi309
    0

    You need to do a little trick, in order to include the language information when you render your URLs:

    <a href="@page.Url?lang=@RenderPage("../MacroScripts/SelectedLanguage.cshtml")">
    

    Sorry that there is no automatic way to do this :) Let me know if it works.

  • ds 191 posts 223 karma points
    Jul 16, 2015 @ 12:32
    ds
    0

    I have made only a tiny change by removing dots

    <a href="@page.Url?lang=@RenderPage("/MacroScripts/SelectedLanguage.cshtml")">
    

    I have also a contact us package

        @{
        using (Html.BeginUmbracoForm<ContactController>("HandleContactForm"))
        {   
            @Html.ValidationSummary(true)
            @Html.AntiForgeryToken()
    
            @Html.TextBoxFor(model => model.Name, new {placeholder = "Ad Soyad", @class="form-control"})
            @Html.ValidationMessageFor(model => model.Name)<br/>
    
            @Html.TextBoxFor(model => model.Email, new {placeholder = "Email Adresi", @class="form-control"})
            @Html.ValidationMessageFor(model => model.Email)<br/>
    
            @Html.TextBoxFor(model => model.Subject, new {placeholder = "Konu", @class="form-control"})
            @Html.ValidationMessageFor(model => model.Subject)<br/>
    
            @Html.TextAreaFor(model => model.Message, new {placeholder = "Mesajınız", @class="form-control", wrap="hard", rows="5"})
            @Html.ValidationMessageFor(model => model.Message)<br/>
    
            <input type="submit" value="Gönder" class="btn btn-primary"/>
        }
    }
    

    I have tried by changing "Culture and hostnames" but of course there is only one root and dictionary items does not work. Is there any way to make it work with your package?

  • dimi309 245 posts 579 karma points
    Jul 17, 2015 @ 20:43
    dimi309
    0

    Hi!

    The dictionary works, but you need to add the languages you use to the Umbraco dictionary and call the SetPageCulture macro from Polyglot, somewhere towards the top of your template, before the lines of code where you access the dictionary.

    Let me know if everything's ok.

  • ds 191 posts 223 karma points
    Jul 19, 2015 @ 19:08
    ds
    0

    Hi Dimitri,

    I have that SetPageCulture macro located on my master template but for example

    @Html.TextBoxFor(model => model.Name, new {placeholder = "Ad Soyad", @class="form-control"})
    

    In this case, How can I add @Umbraco.Field("#Ad Soyad") to that piece of code

  • ds 191 posts 223 karma points
    Jul 21, 2015 @ 18:48
    ds
    0

    I would be very appreciated if you could give any help, Dimitri.

  • dimi309 245 posts 579 karma points
    Jul 23, 2015 @ 19:56
    dimi309
    0

    Hi! Sorry for the delay. I've been offline for a while.. Have you tried adding it without the @? I'm not even sure that @ is needed for "class" either...

  • ds 191 posts 223 karma points
    Jul 24, 2015 @ 10:14
    ds
    0

    Here is the complete code;

        @using System.Web.Mvc.Html
    @using Umbraco.Contact.Controllers
    @using Umbraco.Contact.Models.Form
    @using Umbraco.Web
    @using Umbraco
    @model ContactFormModel
    
    @{
        Html.EnableClientValidation(true);
        Html.EnableUnobtrusiveJavaScript(true);
    }
    
    @if (Convert.ToBoolean(TempData["IsSuccessfull"]))
    {
        <h1>Mesajınız başarı ile gönderildi. Teşekkürler</h1>
    
    }
    
    @{
        using (Html.BeginUmbracoForm<ContactController>("HandleContactForm"))
        {   
            @Html.ValidationSummary(true)
            @Html.AntiForgeryToken()
    
            @Html.TextBoxFor(model => model.Name, new {placeholder [email protected]("#Ad Soyad"), @class="form-control"})
            @Html.ValidationMessageFor(model => model.Name)<br/>
    
            @Html.TextBoxFor(model => model.Email, new {placeholder = "Email Adresi", @class="form-control"})
            @Html.ValidationMessageFor(model => model.Email)<br/>
    
            @Html.TextBoxFor(model => model.Subject, new {placeholder = "Konu", @class="form-control"})
            @Html.ValidationMessageFor(model => model.Subject)<br/>
    
            @Html.TextAreaFor(model => model.Message, new {placeholder = "Mesajınız", @class="form-control", wrap="hard", rows="5"})
            @Html.ValidationMessageFor(model => model.Message)<br/>
    
            <input type="submit" value="Gönder" class="btn btn-primary"/>
        }
    }
    

    What makes the trick is placeholder section ;

    @Html.TextBoxFor(model => model.Name, new {placeholder = "Ad Soyad", @class="form-control"})
    

    I changed it to;

    @Html.TextBoxFor(model => model.Name, new {placeholder [email protected]("#Ad Soyad"), @class="form-control"})
    

    I get the following error; CS0234: The type or namespace name 'Field' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)

  • dimi309 245 posts 579 karma points
    Aug 05, 2015 @ 23:54
    dimi309
    0

    Once again, sorry for the delay but I was on holiday. If you are in a template, it should work the way you have it. If you are in a razor script though (macro) you need to do @Dictionary["fieldName"], without the #. I hope this helps!

  • ds 191 posts 223 karma points
    Aug 08, 2015 @ 09:44
    ds
    0

    Hi Dimitri,

    Hope to had a good holiday. After your suggest, I get the following error;

    CS0234: The type or namespace name 'Dictionary' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)

    @Html.TextBoxFor(model => model.Name, new {placeholder = @Umbraco.Dictionary["AdSoyad"], @class="form-control"})
    

    It does not matter with Umbraco or Umbraco.Dictionary

  • dimi309 245 posts 579 karma points
    Aug 08, 2015 @ 10:52
    dimi309
    0

    Thanks! It went alright :) For use in a template, it's not @Umbraco.Dictionary, but just plain @Dictionary.

  • ds 191 posts 223 karma points
    Aug 09, 2015 @ 09:37
    ds
    0

    I tried both but that piece of code in .cshtml file and use uContactor package.

    but I get even the same error with your suggestion

  • dimi309 245 posts 579 karma points
    Aug 09, 2015 @ 09:45
    dimi309
    0

    That's strange... I have made a test with a macro script that contains only the following and it works:

    @{
    @Dictionary["testField"]
    }
    

    What Umbraco version are you currently using?

  • ds 191 posts 223 karma points
    Aug 10, 2015 @ 08:38
    ds
    0

    Version is 7.2.1, Dimitri

  • dimi309 245 posts 579 karma points
    Aug 13, 2015 @ 21:10
    dimi309
    0

    I am sorry, I have tried but I cannot reproduce this problem :( Could you try the snippet I sent you in a separate macro and let me know if it works on your system?

  • Delly Mellas Nyman 64 posts 316 karma points
    Sep 16, 2015 @ 03:23
    Delly Mellas Nyman
    0

    Hi ds,

    Maybe you can try the newer uContactor package, it comes with built in localization, and you can change your localization within uContactor dictionary.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft