Copied to clipboard

Flag this post as spam?

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


  • David Gregory 87 posts 233 karma points
    Sep 15, 2015 @ 19:26
    David Gregory
    0

    Vorto and navigation menus

    Hi guys

    I'm using Vorto to create a bilingual site. All is brilliant so far but I have one small problem.

    I'm using the navigation code snippet from the partial views area which displays the page name as the navigation links. However, this means that the page names are not translated. So I have two questions:

    1) is there a away Vorto can be used on the page name

    or

    2) if I add a (Vorto) property called "menuTitle" to each page, how would I call that in the navigation loop?

    Thanks David Umbraco 7.2.8

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Sep 16, 2015 @ 06:40
    Dave Woestenborghs
    0

    Hi David,

    I think the only option is number 2.

    In your navigation loop you can do

    @item.GetVortoValue<string>("menuTitle")
    

    Dave

  • David Gregory 87 posts 233 karma points
    Sep 16, 2015 @ 09:04
    David Gregory
    0

    Thanks, but that code doesn't quite work for me it just displays ("MENUTITLE") as the link name

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Sep 16, 2015 @ 09:13
    Dave Woestenborghs
    0

    Maybe you need change this line :

    @{ var selection = CurrentPage.Site().Children.Where("Visible"); }
    

    into

    @{ var selection = Model.Content.AncestorOrSelf("Site").Children.Where("Visible"); }
    

    Strange that i see your code in the e-mail notification i got and not in this post.

    Dave

  • David Gregory 87 posts 233 karma points
    Sep 16, 2015 @ 14:42
    David Gregory
    0

    Sorry Dave, I get a NullReferenceExcpetion on that

    @item.GetVortoValue<string>("menuTitle")
    

    and a ' 'Umbraco.Core.Models.IPublishedContent' has no applicable method named 'IsAncestorOrSelf' but appears to have an extension method by that name.' error before that on

    <li class="@(item.IsAncestorOrSelf(CurrentPage) ? "active" : null)">
    

    It must be possible otherwise no Vorto site would be truly multilingual if nav and breadcrumbs only show page Name

    Thanks for your help. David

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Sep 16, 2015 @ 15:15
    Dave Woestenborghs
    0

    Can you post your entire code.

    It will be easier to see where it goes wrong.

    Dave

  • David Gregory 87 posts 233 karma points
    Sep 16, 2015 @ 15:25
    David Gregory
    0

    I can't get it to show in th editor, here is an image that hopefully will work.

    enter image description here

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Sep 16, 2015 @ 15:31
    Dave Woestenborghs
    0

    Does it out put anything when you do

    @item.Name
    

    Dave

  • David Gregory 87 posts 233 karma points
    Sep 16, 2015 @ 15:52
    David Gregory
    0

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS1973: 'Umbraco.Core.Models.IPublishedContent' has no applicable method named 'IsAncestorOrSelf' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

    enter image description here

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Sep 16, 2015 @ 15:54
    Dave Woestenborghs
    0

    Change that to

    @item.IsAncestorOrSelf(Model.Content)
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Sep 16, 2015 @ 15:56
    Dave Woestenborghs
    0

    The problem probably is caused because your syntax was using dynamics and mine was using strongly typed IPublished Content

    Maybe read these articles to get a insight in the difference : http://www.zpqrtbnk.net/posts/strongly-typed-models-1

Please Sign in or register to post replies

Write your reply to:

Draft