create nevigation new menu item and link to another website
Hello All,
How can i add new menu item to the menu and link to another website example i like to add new item called Umbraco and when click on the menu tab Umbraco it will take user to the Umbraco website, Below is my snapshot my example website and content.
One way that you could do it, is by adding an list element outside the foreach loop in the umbTopNavigation.cshtml file and then hardcode the umbraco URL.
Go to the settings section, and open the Partial Views folder and find the umbTopNavigation.cshtml.
The replace the code with this:
@inherits UmbracoTemplatePage @{ // Model.Content is the current page that we're on // AncestorsOrSelf is all of the ancestors this page has in the tree // (1) means: go up to level 1 and stop looking for more ancestors when you get there // First() gets the first ancestor found (the home page, on level 1) var homePage = CurrentPage.AncestorsOrSelf(1).First();
// The menu items we want are all of the children of the homepage // We also check if "Hide in navigation" is on in the menu, we shouldn't show hidden items var menuItems = homePage.Children.Where("UmbracoNaviHide == false"); } <!-- Nav --> <nav id="nav" class="skel-panels-fixed"> <ul> @* If the Url of the current page is "/" then we want to add the class "current_page_item" *@ @* Otherwise, we set the class to null, that way it will not even be added to the <li> element *@ <li class="@(CurrentPage.Url == "/" ? "current_page_item" : null)"><a href="/">Home</a></li>
@foreach (var item in menuItems) { @* If the Id of the item is the same as the Id of the current page then we want to add the class "current_page_item" *@ @* Otherwise, we set the class to null, that way it will not even be added to the <li> element *@ <li class="@(CurrentPage.Id == item.Id ? "current_page_item" : null)"><a href="@item.Url">@item.Name</a></li>
This is a easy way you could solve it. Or you could try take a look at the uComponents URL Picker, with this you can link internal and external, I donĀ“t know long the team is with an v7 version.http://ucomponents.org/data-types/url-picker/
Hello,
When I tried to do like said, I get an exception:
An error occured
File '/TestMainNavigation.cshtml' is outside this filesystem's root.
Exception Details
Umbraco.Core.IO.FileSecurityException: File '/TestMainNavigation.cshtml' is outside this filesystem's root.
at Umbraco.Core.IO.PhysicalFileSystem.GetFullPath(String path)
at Umbraco.Core.IO.PhysicalFileSystem.FileExists(String path)
at Umbraco.Core.Persistence.Repositories.PartialViewRepository.Get(String id)
at Umbraco.Core.Services.FileService.GetPartialView(String path)
at Umbraco.Web.Editors.CodeFileController.CreateOrUpdatePartialView(CodeFileDisplay display, String systemDirectory, Func2 getView, Func3 saveView, Func4 createView)
at Umbraco.Web.Editors.CodeFileController.CreateOrUpdatePartialView(CodeFileDisplay display)
at Umbraco.Web.Editors.CodeFileController.PostSave(CodeFileDisplay display)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.
create nevigation new menu item and link to another website
Hello All,
How can i add new menu item to the menu and link to another website example i like to add new item called Umbraco and when click on the menu tab Umbraco it will take user to the Umbraco website, Below is my snapshot my example website and content.
Best Regrads.
MC
Hi MC,
One way that you could do it, is by adding an list element outside the foreach loop in the umbTopNavigation.cshtml file and then hardcode the umbraco URL.
Go to the settings section, and open the Partial Views folder and find the umbTopNavigation.cshtml.
The replace the code with this:
This is a easy way you could solve it. Or you could try take a look at the uComponents URL Picker, with this you can link internal and external, I donĀ“t know long the team is with an v7 version.http://ucomponents.org/data-types/url-picker/
But for now I will use the straightforward method, and when uComponents in some form is ready for v7 you could take a look if there are some better solutions. You could try ask Lee how long they are with a v7-ish version. http://our.umbraco.org/projects/backoffice-extensions/ucomponents/questionssuggestions/46392-uComponents-v7-Expectations
Hope this helps.
/Dennis
Thank you Dennis for your time to explain. i am truely appreciate your help.
MC.
Hello, When I tried to do like said, I get an exception: An error occured
File '/TestMainNavigation.cshtml' is outside this filesystem's root.
Exception Details
Umbraco.Core.IO.FileSecurityException: File '/TestMainNavigation.cshtml' is outside this filesystem's root.
at Umbraco.Core.IO.PhysicalFileSystem.GetFullPath(String path) at Umbraco.Core.IO.PhysicalFileSystem.FileExists(String path) at Umbraco.Core.Persistence.Repositories.PartialViewRepository.Get(String id) at Umbraco.Core.Services.FileService.GetPartialView(String path) at Umbraco.Web.Editors.CodeFileController.CreateOrUpdatePartialView(CodeFileDisplay display, String systemDirectory, Func
2 getView, Func
3 saveView, Func4 createView) at Umbraco.Web.Editors.CodeFileController.CreateOrUpdatePartialView(CodeFileDisplay display) at Umbraco.Web.Editors.CodeFileController.PostSave(CodeFileDisplay display) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary
2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.is working on a reply...