Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 248 Vote(s) - 3.59 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dropdown menu in Umbraco Cms

#1
This is my Master layout page. I am generating the dynamic menu, but clicking the dropdown does not show any items. What am I doing wrong?

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Master>
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@Umbraco.Field("siteTitle")</title>
<meta name="description" content="@Umbraco.Field("metaDescription", recursive: true)">
<meta name="keyword" content="@Umbraco.Field("metaKeywords", recursive: true)">
<link href="~/Content/bootstrap.css" rel="stylesheet" />

<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
</head>
<body>


This is the start of the navigation section.

<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
@{ IPublishedContent root = Model.Content.AncestorOrSelf(1); }
<ul class="nav navbar-nav">
<li class="@((Model.Content.Name == root.Name) ? "active" : null)">
<a href="/">@root.Name</a></li>
</li>
@foreach (IPublishedContent menuItem in root.Children.Where(x => x.IsVisible())) {
<li class="@((menuItem.Name == Model.Content.Name) ? "active" : null)">
<a href="@menuItem.Url">@menuItem.Name</a>
</li>
}

This is where the code starts to not work.

<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href='@Model.Content.AncestorOrSelf(1).Children.Where(x => x.DocumentTypeAlias == "projectsMain")'>Our Proj<span class="caret"></span></a>
<ul class="dropdown-menu">
@{
IQueryable projectsDropdown =
Model.Content.AncestorOrSelf(1)
.Children
.Where(x => x.DocumentTypeAlias == "projectsMain")
.First()
.Children
.Where("Visible")
.OrderBy("Name");

}
@foreach(IPublishedContent project in projectsDropdown){
var prevalue = project.GetPropertyValue<int>("projectStatus");
if(Umbraco.GetPreValueAsString(prevalue) == "Completed"){
<li><a href="@project.Url">@project.Name</a></li>
}
}
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>

@RenderBody();

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/jquery-2.2.0.min.js"></script>
</body>
</html>
Reply

#2
Have you tried debugging your way through? Have you checked the generated HTML source to see if there actually are items in the dropdown-menu ul?

Which Umbraco version are you using? Looks like 7.x - so there are much easier ways to do some of what you do. Like @CurrentPage.Site() to get root node.

You are including both bootstrap.js and bootstrap.min.js, that might mess things up, as well as including what looks like two versions of jQuery?

Also, you are including (the jquery-2.2.0.js) jQuery after bootstrap.js, that might also cause problems.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through