Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
We have been stuck on this for a while and what ever we try does not seem to work and apparently this is not an Umbraco v8 bug. Although Umbraco will not tell us how to do this?? We are new to umbraco and working in Umbraco cloud v8.
We are trying to add anchor links to a dynamic menu. Our client creates the anchor link with the anchor link tool.
We thentry and add the link to the dynamic menu.
This should give us the path /services#communication, but we get the following services/communication and therefore does not work.
Our dynamic menu code is below
@helper RenderPageLink(IPublishedContent item)
bool isActive = Model.Id == item.Id;
if (!item.Value<bool>("disableDropdown") && item.Children != null && item.Children.Where(x => x.IsVisible()).Any())
IEnumerable<IPublishedContent> childItems = item.Children.Where(x => x.IsVisible());
bool textOnly = item.Value<bool>("textOnlyInNavigation");
<a class="dropdown-toggle @(textOnly ? "textonly" : null) @(isActive ? "active" : null)" data-toggle="dropdown" href="@item.Url">@item.Name <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li role="presentation" class="@(isActive ? "active" : null)">
Can someone point us in the right direction. This should be simple to achieve so we are missing something obvious.
This problem sounds familiar to me. As I recall, the problem has something to do with MVC Razor. Have you tried Encoding the URL's?
and derivatives of
<a href="@HttpUtility.UrlPathEncode("#" + item.Url)">@item.Name</a>
to try and force the "#" but unfortunately no change. we still get services/communication where we need services#communication.
We can do this manually but then our client will not be able to add anchors when they want.
This is the only CMS we have used that seems to have an issue with this simple task.
Ok, I am nearly there. I have added this
<a href="@HttpUtility.UrlPathEncode(Request.Url.AbsoluteUri + "services#" + item.Name("anchorServices"))">@item.Name </a>
which works for the drop down menu, but now the top menus if they do not have a drop down have the "services#" in front of the path so they do not work.
ie our about us link is now /services#aboutus where it should be /aboutus.
Does any one have any ideas?
It's not exactly clear what you are trying to achieve. Your render page link code is in no way connected to the list of anchor links you are creating. I think you should also show us the @RenderChildren() method code. Also can you show us the example of content that has the dynamic links?
Reading your helper method it says
if not disable dropdown + has children
then render dropdown html
and pass the children into a RenderChildren helper method
render out node name and url
There is no code there, that says access a property on my node that has a list of the in-page dynamic links.
As i say, show us all of the code, tell us exactly what you are trying to achieve and give us the structure of the documents you have set up, then I am sure I can help you out.
What happens if you write the link using @HTML.Raw()?
@HTML.Raw("<a href="HttpUtility.UrlPathEncode(Request.Url.AbsoluteUri + "services#" + item.Name("anchorServices"))">@item.Name </a>")
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted