Add WebCms

This commit is contained in:
2016-11-07 12:56:17 -05:00
parent dfe92218f4
commit 15911f33c0
2750 changed files with 365672 additions and 133 deletions
@@ -0,0 +1,24 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet makes a breadcrumb of parents using an unordered html list.
How it works:
- It uses the Ancestors() method to get all parents and then generates links so the visitor can go back
- Finally it outputs the name of the current page (without a link)
*@
@{ var selection = CurrentPage.Ancestors(); }
@if (selection.Any())
{
<ul class="breadcrumb">
@* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@
@foreach (var item in selection.OrderBy("Level"))
{
<li><a href="@item.Url">@item.Name</a> <span class="divider">/</span></li>
}
@* Display the current page as the last item in the list *@
<li class="active">@CurrentPage.Name</li>
</ul>
}
@@ -0,0 +1,66 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Controllers
@{
var profileModel = Members.GetCurrentMemberProfileModel();
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco_client/ui/jquery.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
var success = TempData["ProfileUpdateSuccess"] != null;
}
@*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@
@Html.RenderJsHere()
@if (Members.IsLoggedIn() && profileModel != null)
{
if (success)
{
@* This message will show if RedirectOnSucces is set to false (default) *@
<p>Profile updated</p>
}
using (Html.BeginUmbracoForm<UmbProfileController>("HandleUpdateProfile"))
{
<fieldset>
<legend>Edit profile</legend>
@Html.ValidationSummary("profileModel", true)
@Html.LabelFor(m => profileModel.Name)
@Html.TextBoxFor(m => profileModel.Name)
@Html.ValidationMessageFor(m => profileModel.Name)
<br />
@Html.LabelFor(m => profileModel.Email)
@Html.TextBoxFor(m => profileModel.Email)
@Html.ValidationMessageFor(m => profileModel.Email)
<br />
@for (var i = 0; i < profileModel.MemberProperties.Count; i++)
{
@Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name)
@*
By default this will render a textbox but if you want to change the editor template for this property you can
easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
render your specific editor template like:
@Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
*@
@Html.EditorFor(m => profileModel.MemberProperties[i].Value)
@Html.HiddenFor(m => profileModel.MemberProperties[i].Alias)
<br />
}
<button>Save</button>
</fieldset>
}
}
@@ -0,0 +1 @@
@inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>
@@ -0,0 +1 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@@ -0,0 +1,50 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to display a gallery of images from media the media section.
Works with either a 'Single Media Picker' or a 'Multiple Media Picker' macro parameter (see below).
How it works:
- Confirm the macro parameter has been passed in with a value
- Loop through all the media Id's passed in (might be a single item, might be many)
- Display any individual images, as well as any folders of images
Macro Parameters To Create, for this macro to work:
Alias:mediaIds Name:Select folders and/or images Type: Multiple Media Picker
Type: (note: you can use a Single Media Picker if that's more appropriate to your needs)
*@
@{ var mediaIds = Model.MacroParameters["mediaIds"]; }
@if (mediaIds != null)
{
<ul class="thumbnails">
@foreach (var mediaId in mediaIds.ToString().Split(','))
{
var media = Umbraco.Media(mediaId);
@* a single image *@
if (media.DocumentTypeAlias == "Image")
{
@Render(media);
}
@* a folder with images under it *@
if (media.Children("Image").Any())
{
foreach (var image in media.Children("Image"))
{
@Render(image);
}
}
}
</ul>
}
@helper Render(dynamic item)
{
<li class="span2">
<a href="@item.umbracoFile.src" class="thumbnail">
<img src="@item.umbracoFile.src" alt="@item.Name" />
</a>
</li>
}
@@ -0,0 +1,24 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet makes a list of links to the of parents of the current page using an unordered html list.
How it works:
- It uses the Ancestors() method to get all parents and then generates links so the visitor can go back
- Finally it outputs the name of the current page (without a link)
*@
@{ var selection = CurrentPage.Ancestors(); }
@if (selection.Any())
{
<ul>
@* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@
@foreach (var item in selection.OrderBy("Level"))
{
<li><a href="@item.Url">@item.Name</a> &raquo;</li>
}
@* Display the current page as the last item in the list *@
<li>@CurrentPage.Name</li>
</ul>
}
@@ -0,0 +1,33 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to list all child pages under a specific page in the content tree.
How it works:
- Confirm the startNodeId macro parameter has been passed in with a value
- Loop through all child pages
- Display a list of link to those pages, sorted by the value of the propertyAlias
Macro Parameters To Create, for this macro to work:
Alias:startNodeId Name:Select starting page Type:Content Picker
*@
@{ var startNodeId = Model.MacroParameters["startNodeId"]; }
@if (startNodeId != null)
{
@* Get the starting page *@
var startNode = Umbraco.Content(startNodeId);
var selection = startNode.Children.Where("Visible");
if (selection.Any())
{
<ul>
@foreach (var item in selection)
{
<li>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
}
}
@@ -0,0 +1,15 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{ var selection = CurrentPage.Children.Where("Visible"); }
@if (selection.Any())
{
<ul>
@foreach (var item in selection)
{
<li>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
}
@@ -0,0 +1,11 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{ var selection = CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"); }
@* OrderBy() takes the property to sort by and optionally order desc/asc *@
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
@@ -0,0 +1,11 @@
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{ var selection = CurrentPage.Children.Where("Visible").OrderBy("Name"); }
@* OrderBy() takes the property to sort by *@
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
@@ -0,0 +1,26 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to list all child pages with a specific property, sorted by the value of that property.
How it works:
- Confirm the propertyAlias macro parameter has been passed in with a value
- Loop through all child pages that have the propertyAlias
- Display a list of link to those pages, sorted by the value of the propertyAlias
Macro Parameters To Create, for this macro to work:
Alias:propertyAlias Name:Property Alias Type:Textbox
*@
@{ var propertyAlias = Model.MacroParameters["propertyAlias"]; }
@if (propertyAlias != null)
{
var selection = CurrentPage.Children.Where("Visible").OrderBy(propertyAlias);
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}
@@ -0,0 +1,25 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet shows how simple it is to fetch only children of a certain Document Type using Razor.
Be sure to change "DocumentTypeAlias" below to match your needs, such as "TextPage" or "NewsItems".
(You can find the alias of your Document Type by editing it in the Settings section)
*@
@{ var selection = CurrentPage.Children("DocumentTypeAlias").Where("Visible"); }
@*
As an example of more querying, if you have a true/false property with the alias of shouldBeFeatured:
var selection= CurrentPage.Children("DocumentTypeAlias").Where("shouldBeFeatured == true").Where("Visible");
*@
@if (selection.Any())
{
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}
@@ -0,0 +1,61 @@
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@*
This snippet creates links for every single page (no matter how deep) below
the page currently being viewed by the website visitor, displayed as nested unordered html lists.
*@
@{ var selection = CurrentPage.Children.Where("Visible"); }
@* Ensure that the Current Page has children *@
@if (selection.Any())
{
@* Get the first page in the children, where the property umbracoNaviHide is not True *@
var naviLevel = CurrentPage.FirstChild().Where("Visible").Level;
@* Add in level for a CSS hook *@
<ul class="level-@naviLevel">
@* For each child page where the property umbracoNaviHide is not True *@
@foreach (var item in selection)
{
<li>
<a href="@item.Url">@item.Name</a>
@* if this child page has any children, where the property umbracoNaviHide is not True *@
@if (item.Children.Where("Visible").Any())
{
@* Call our helper to display the children *@
@childPages(item.Children)
}
</li>
}
</ul>
}
@helper childPages(dynamic selection)
{
@* Ensure that we have a collection of pages *@
if (selection.Any())
{
@* Get the first page in pages and get the level *@
var naviLevel = selection.First().Level;
@* Add in level for a CSS hook *@
<ul class="level-@(naviLevel)">
@foreach (var item in selection.Where("Visible"))
{
<li>
<a href="@item.Url">@item.Name</a>
@* if the this page has any children, where the property umbracoNaviHide is not True *@
@if (item.Children.Where("Visible").Any())
{
@* Call our helper to display the children *@
@childPages(item.Children)
}
</li>
}
</ul>
}
}
@@ -0,0 +1,33 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to display a series of images from a media folder.
How it works:
- Confirm the macro parameter has been passed in with a value
- Loop through all the media Id's passed in (might be a single item, might be many)
- Display any individual images, as well as any folders of images
Macro Parameters To Create, for this macro to work:
Alias:mediaId Name:Select folder with images Type:Single Media Picker
*@
@{ var mediaId = Model.MacroParameters["mediaId"]; }
@if (mediaId != null)
{
@* Get all the media item associated with the id passed in *@
var media = Umbraco.Media(mediaId);
var selection = media.Children("Image");
if (selection.Any())
{
<ul>
@foreach (var item in selection)
{
<li>
<img src="@item.umbracoFile" alt="@item.Name" />
</li>
}
</ul>
}
}
@@ -0,0 +1,41 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@{
var loginModel = new LoginModel();
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco_client/ui/jquery.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
}
@* NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed *@
@Html.RenderJsHere()
@using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))
{
<fieldset>
<legend>Login</legend>
@Html.ValidationSummary("loginModel", true)
@Html.LabelFor(m => loginModel.Username)
@Html.TextBoxFor(m => loginModel.Username)
@Html.ValidationMessageFor(m => loginModel.Username)
<br />
@Html.LabelFor(m => loginModel.Password)
@Html.PasswordFor(m => loginModel.Password)
@Html.ValidationMessageFor(m => loginModel.Password)
<br />
<button>Login</button>
</fieldset>
}
@@ -0,0 +1,43 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@{
var loginStatusModel = Members.GetCurrentLoginStatus();
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco_client/ui/jquery.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
var logoutModel = new PostRedirectModel();
@*
Here you can specify a redirect URL for after logging out, by default umbraco will simply
redirect to the current page. Example to redirect to the home page:
logoutModel.RedirectUrl = "/";
*@
}
@* NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed *@
@Html.RenderJsHere()
@if (loginStatusModel.IsLoggedIn)
{
<p>You are currently logged in as @loginStatusModel.Name</p>
using (Html.BeginUmbracoForm<UmbLoginStatusController>("HandleLogout"))
{
<fieldset>
<legend>Logout</legend>
<button>Logout</button>
</fieldset>
@Html.HiddenFor(m => logoutModel.RedirectUrl)
}
}
@@ -0,0 +1,21 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet lists the items from a Multinode tree picker, using the pickers default settings.
Content Values stored as xml.
To get it working with any site's data structure, set the selection equal to the property which has the
multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property).
*@
@{ var selection = CurrentPage.PropertyWithPicker.Split(','); }
<ul>
@foreach (var id in selection)
{
var item = Umbraco.Content(id);
<li>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
@@ -0,0 +1,18 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet displays a list of links of the pages immediately under the top-most page in the content tree.
This is the home page for a standard website.
It also highlights the current active page/section in the navigation with the css class "current".
*@
@{ var selection = CurrentPage.Site().Children.Where("Visible"); }
<ul>
@foreach (var item in selection)
{
<li class="@(item.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
@@ -0,0 +1,104 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Controllers
@{
@*
You can specify a custom member type alias in the constructor, the default is 'Member'
for example, to use 'Custom Member' you'd use this syntax:
var registerModel = Members.CreateRegistrationModel("Custom Member");
*@
var registerModel = Members.CreateRegistrationModel();
@*
Configurable here:
registerModel.RedirectUrl - Optional. What path to redirect to if registration is successful.
By default the member will be redirected to the current umbraco page
unless this is specified.
registerModel.UsernameIsEmail - the default is true
if you want the username to be different from the email
address, set this to true and add a new Username field in
the form below
@Html.LabelFor(m => registerModel.Username)
@Html.TextBoxFor(m => registerModel.Username)
@Html.ValidationMessageFor(m => registerModel.Username)
*@
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco_client/ui/jquery.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
var success = TempData["FormSuccess"] != null;
}
@*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@
@Html.RenderJsHere()
@if (success)
{
@* This message will show if RedirectOnSucces is set to false (default) *@
<p>Registration succeeeded.</p>
}
else
{
using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))
{
<fieldset>
<legend>Register Member</legend>
@Html.ValidationSummary("registerModel", true)
@Html.LabelFor(m => registerModel.Name)
@Html.TextBoxFor(m => registerModel.Name)
@Html.ValidationMessageFor(m => registerModel.Name)
<br />
@Html.LabelFor(m => registerModel.Email)
@Html.TextBoxFor(m => registerModel.Email)
@Html.ValidationMessageFor(m => registerModel.Email)
<br />
@Html.LabelFor(m => registerModel.Password)
@Html.PasswordFor(m => registerModel.Password)
@Html.ValidationMessageFor(m => registerModel.Password)
<br />
@if (registerModel.MemberProperties != null)
{
@*
It will only displays properties marked as "Member can edit" on the "Info" tab of the Member Type.
*@
for (var i = 0; i < registerModel.MemberProperties.Count; i++)
{
@Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
@*
By default this will render a textbox but if you want to change the editor template for this property you can
easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
render your specific editor template like:
@Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
*@
@Html.EditorFor(m => registerModel.MemberProperties[i].Value)
@Html.HiddenFor(m => registerModel.MemberProperties[i].Alias)
<br />
}
}
@Html.HiddenFor(m => registerModel.MemberTypeAlias)
@Html.HiddenFor(m => registerModel.RedirectUrl)
@Html.HiddenFor(m => registerModel.UsernameIsEmail)
<button>Register</button>
</fieldset>
}
}
@@ -0,0 +1,42 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet makes a list of links of all visible pages of the site, as nested unordered html lists.
How it works:
- It uses a custom Razor helper called Traverse() to select and display the markup and links.
*@
@{ var selection = CurrentPage.Site(); }
<div class="sitemap">
@* Render the sitemap by passing the root node to the traverse helper, below *@
@Traverse(selection)
</div>
@* Helper method to travers through all descendants *@
@helper Traverse(dynamic node)
{
@* Update the level to reflect how deep you want the sitemap to go *@
var maxLevelForSitemap = 4;
@* Select visible children *@
var selection = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
@* If any items are returned, render a list *@
if (selection.Any())
{
<ul>
@foreach (var item in selection)
{
<li class="level-@item.Level">
<a href="@item.Url">@item.Name</a>
@* Run the traverse helper again for any child pages *@
@Traverse(item)
</li>
}
</ul>
}
}