Also clean up v6 snippets

This commit is contained in:
Sebastiaan Janssen
2014-03-07 09:46:33 +01:00
parent 1511ad58b2
commit a48fe40675
19 changed files with 73 additions and 101 deletions

View File

@@ -3,7 +3,6 @@
@using System.Web.Mvc.Html @using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc @using ClientDependency.Core.Mvc
@using Umbraco.Web @using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers @using Umbraco.Web.Controllers
@{ @{
@@ -16,7 +15,6 @@
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js"); Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
var success = TempData["ProfileUpdateSuccess"] != null; 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*@ @*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@
@@ -26,7 +24,7 @@
{ {
if (success) if (success)
{ {
// This message will show if RedirectOnSucces is set to false (default) @* This message will show if RedirectOnSucces is set to false (default) *@
<p>Profile updated</p> <p>Profile updated</p>
} }

View File

@@ -1,7 +1,7 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage @inherits Umbraco.Web.Macros.PartialViewMacroPage
<ul> <ul>
@*OrderBy() takes the property to sort by and optionally order desc/asc *@ @* OrderBy() takes the property to sort by and optionally order desc/asc *@
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc")) @foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"))
{ {

View File

@@ -1,6 +1,6 @@
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<ul> <ul>
@*OrderBy() takes the property to sort by*@ @* OrderBy() takes the property to sort by *@
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("Name")) @foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("Name"))
{ {
<li><a href="@page.Url">@page.Name</a></li> <li><a href="@page.Url">@page.Name</a></li>

View File

@@ -4,15 +4,12 @@
Show:True Alias:propertyAlias Name:Property Alias Type:Textstring Show:True Alias:propertyAlias Name:Property Alias Type:Textstring
*@ *@
@{ @{
@* Get the property alias we want to filter on from the macro parameter *@ @* Get the property alias we want to filter on from the macro parameter *@
var propertyAlias = Model.MacroParameters["propertyAlias"]; var propertyAlias = Model.MacroParameters["propertyAlias"];
var selection = CurrentPage.Children.Where("Visible").OrderBy(propertyAlias); var selection = CurrentPage.Children.Where("Visible").OrderBy(propertyAlias);
} }
<ul> <ul>
@foreach (var page in selection) @foreach (var page in selection)
{ {

View File

@@ -7,7 +7,6 @@
Settings section). Settings section).
*@ *@
@{ @{
@*Build a query and return the visible items *@ @*Build a query and return the visible items *@
var selection= CurrentPage.Textpages.Where("Visible"); var selection= CurrentPage.Textpages.Where("Visible");
@@ -18,7 +17,6 @@
*@ *@
} }
@*Determine if there are any nodes in the selection, then render list *@ @*Determine if there are any nodes in the selection, then render list *@
@if(selection.Any()){ @if(selection.Any()){

View File

@@ -16,7 +16,7 @@
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.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*@ @* NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed *@
@Html.RenderJsHere() @Html.RenderJsHere()
@using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin")) @using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))

View File

@@ -16,16 +16,15 @@
var logoutModel = new PostRedirectModel(); var logoutModel = new PostRedirectModel();
/* @*
* Here you can specify a redirect URL for after logging out, by default umbraco will simply 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: redirect to the current page. Example to redirect to the home page:
*
* logoutModel.RedirectUrl = "/"; logoutModel.RedirectUrl = "/";
* *@
*/
} }
@*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@ @* NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed *@
@Html.RenderJsHere() @Html.RenderJsHere()
@if (loginStatusModel.IsLoggedIn) @if (loginStatusModel.IsLoggedIn)

View File

@@ -6,9 +6,8 @@
the css class "current". the css class "current".
*@ *@
@{ @{
@*Get the root of the website *@ @* Get the root of the website *@
var root = CurrentPage.AncestorOrSelf(1); var root = CurrentPage.AncestorOrSelf(1);
} }

View File

@@ -3,37 +3,34 @@
@using System.Web.Mvc.Html @using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc @using ClientDependency.Core.Mvc
@using Umbraco.Web @using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers @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");
* 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(); var registerModel = Members.CreateRegistrationModel();
/* @*
* Configurable here: Configurable here:
*
* registerModel.RedirectUrl - Optional. What path to redirect to if registration is successful. registerModel.RedirectUrl - Optional. What path to redirect to if registration is successful.
* By default the member will be redirected to the current umbraco page By default the member will be redirected to the current umbraco page
* unless this is specified. unless this is specified.
*
* registerModel.UsernameIsEmail - the default is true registerModel.UsernameIsEmail - the default is true
* if you want the username to be different from the email if you want the username to be different from the email
* address, set this to true and add a new Username field in address, set this to true and add a new Username field in
* the form below the form below
*
* @Html.LabelFor(m => registerModel.Username) @Html.LabelFor(m => registerModel.Username)
* @Html.TextBoxFor(m => registerModel.Username) @Html.TextBoxFor(m => registerModel.Username)
* @Html.ValidationMessageFor(m => registerModel.Username) @Html.ValidationMessageFor(m => registerModel.Username)
*/ *@
Html.EnableClientValidation(); Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript(); Html.EnableUnobtrusiveJavaScript();
@@ -49,16 +46,16 @@
@if (success) @if (success)
{ {
// This message will show if RedirectOnSucces is set to false (default) @* This message will show if RedirectOnSucces is set to false (default) *@
<p>Registration succeeeded.</p> <p>Registration succeeeded.</p>
} }
else else
{ {
using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember")) using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))
{ {
<fieldset> <fieldset>
<legend>Register Member</legend> <legend>Register Member</legend>
@Html.ValidationSummary("registerModel", true) @Html.ValidationSummary("registerModel", true)
@Html.LabelFor(m => registerModel.Name) @Html.LabelFor(m => registerModel.Name)
@@ -75,8 +72,9 @@ else
@Html.PasswordFor(m => registerModel.Password) @Html.PasswordFor(m => registerModel.Password)
@Html.ValidationMessageFor(m => registerModel.Password) @Html.ValidationMessageFor(m => registerModel.Password)
<br /> <br />
@if (registerModel.MemberProperties != null) { @if (registerModel.MemberProperties != null)
{
for (var i = 0; i < registerModel.MemberProperties.Count; i++) for (var i = 0; i < registerModel.MemberProperties.Count; i++)
{ {
@Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name) @Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
@@ -87,10 +85,10 @@ else
} }
@Html.HiddenFor(m => registerModel.MemberTypeAlias) @Html.HiddenFor(m => registerModel.MemberTypeAlias)
@Html.HiddenFor(m => registerModel.RedirectUrl) @Html.HiddenFor(m => registerModel.RedirectUrl)
@Html.HiddenFor(m => registerModel.UsernameIsEmail) @Html.HiddenFor(m => registerModel.UsernameIsEmail)
<button>Register</button> <button>Register</button>
</fieldset> </fieldset>
} }
} }

View File

@@ -1,20 +1,20 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage @inherits Umbraco.Web.Macros.PartialViewMacroPage
@*Render the sitemap by passing the root node to the traverse helper*@ @* Render the sitemap by passing the root node to the traverse helper *@
<div class="sitemap"> <div class="sitemap">
@Traverse(CurrentPage.AncestorOrSelf()) @Traverse(CurrentPage.AncestorOrSelf())
</div> </div>
@*Helper method to travers through all descendants*@ @* Helper method to travers through all descendants *@
@helper Traverse(dynamic node) @helper Traverse(dynamic node)
{ {
@* Update the level to reflect how deep you want the sitemap to go *@ @* Update the level to reflect how deep you want the sitemap to go *@
var maxLevelForSitemap = 4; var maxLevelForSitemap = 4;
@*Select visible children *@ @* Select visible children *@
var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap); var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
@*If any items are returned, render a list *@ @* If any items are returned, render a list *@
if (items.Any()) if (items.Any())
{ {
<ul> <ul>
@@ -23,7 +23,7 @@
<li class="level-@item.Level"> <li class="level-@item.Level">
<a href="@item.Url">@item.Name</a> <a href="@item.Url">@item.Name</a>
@*Run the traverse helper again *@ @* Run the traverse helper again *@
@Traverse(item) @Traverse(item)
</li> </li>
} }

View File

@@ -11,7 +11,5 @@
@Library.NodeById(1233) @Library.NodeById(1233)
*@ *@
@* The fun starts here *@ @* The fun starts here *@

View File

@@ -2,8 +2,7 @@
<ul> <ul>
@*OrderBy() takes the property to sort by and optionally order desc/asc *@ @* OrderBy() takes the property to sort by and optionally order desc/asc *@
@foreach (var page in Model.Children.Where("Visible").OrderBy("CreateDate desc")) @foreach (var page in Model.Children.Where("Visible").OrderBy("CreateDate desc"))
{ {
<li><a href="@page.Url">@page.Name</a></li> <li><a href="@page.Url">@page.Name</a></li>

View File

@@ -1,8 +1,7 @@
@inherits umbraco.MacroEngines.DynamicNodeContext @inherits umbraco.MacroEngines.DynamicNodeContext
<ul> <ul>
@*OrderBy() takes the property to sort by*@ @* OrderBy() takes the property to sort by *@
@foreach (var page in Model.Children.Where("Visible").OrderBy("Name")) @foreach (var page in Model.Children.Where("Visible").OrderBy("Name"))
{ {
<li><a href="@page.Url">@page.Name</a></li> <li><a href="@page.Url">@page.Name</a></li>

View File

@@ -5,7 +5,6 @@
Show:True Alias:propertyAlias Name:Property Alias Type:Textstring Show:True Alias:propertyAlias Name:Property Alias Type:Textstring
*@ *@
@{ @{
@* Get the property alias we want to filter on from the macro parameter *@ @* Get the property alias we want to filter on from the macro parameter *@
@@ -13,7 +12,6 @@
var selection = Model.Children.Where("Visible").OrderBy(propertyAlias); var selection = Model.Children.Where("Visible").OrderBy(propertyAlias);
} }
<ul> <ul>
@foreach (var page in selection) @foreach (var page in selection)
{ {

View File

@@ -7,9 +7,8 @@
Settings section). Settings section).
*@ *@
@{ @{
@*Build a query and return the visible items *@ @* Build a query and return the visible items *@
var selection= Model.Textpages.Where("Visible"); var selection= Model.Textpages.Where("Visible");
@* @*
@@ -18,8 +17,7 @@
*@ *@
} }
@* Determine if there are any nodes in the selection, then render list *@
@*Determine if there are any nodes in the selection, then render list *@
@if(selection.Any()){ @if(selection.Any()){
<ul> <ul>

View File

@@ -1,5 +1,3 @@
@inherits umbraco.MacroEngines.DynamicNodeContext @inherits umbraco.MacroEngines.DynamicNodeContext
@* @*
@@ -7,7 +5,6 @@ Macro Parameters To Create, for this macro to work:
Show:True Alias:mediaId Name:Media Folder ID Type:MediaCurrent Show:True Alias:mediaId Name:Media Folder ID Type:MediaCurrent
*@ *@
@if (Parameter.mediaId != null) @if (Parameter.mediaId != null)
{ {
@* Get the media folder as a dynamic node *@ @* Get the media folder as a dynamic node *@

View File

@@ -12,7 +12,6 @@
var selection = Model.PropertyWithPicker; var selection = Model.PropertyWithPicker;
} }
@* Lists each selected value from the picker as a link *@ @* Lists each selected value from the picker as a link *@
<ul> <ul>
@foreach(var id in selection){ @foreach(var id in selection){

View File

@@ -6,9 +6,8 @@
the css class "current". the css class "current".
*@ *@
@{ @{
@*Get the root of the website *@ @* Get the root of the website *@
var root = Model.AncestorOrSelf(1); var root = Model.AncestorOrSelf(1);
} }

View File

@@ -1,38 +1,34 @@
@inherits umbraco.MacroEngines.DynamicNodeContext @inherits umbraco.MacroEngines.DynamicNodeContext
@{ @* Render the sitemap by passing the root node to the traverse helper *@
@* Walk up the tree from the current page to get the root node *@ <div class="sitemap">
var rootNode = Model.AncestorOrself(1);
}
@*Render the sitemap by passing the root node to the traverse helper*@
<div class="sitemap">
@traverse(@Model.AncestorOrSelf()) @traverse(@Model.AncestorOrSelf())
</div> </div>
@* Helper method to travers through all descendants *@
@helper traverse(dynamic node)
{
@* If a MaxLevelForSitemap parameter is passed to the macro, otherwise default to 4 levels *@
@*Helper method to travers through all descendants*@ var maxLevelForSitemap = String.IsNullOrEmpty(Parameter.MaxLevelForSitemap) ? 4 : int.Parse(Parameter.MaxLevelForSitemap);
@helper traverse(dynamic node){
@*If a MaxLevelForSitemap parameter is passed to the macro, otherwise default to 4 levels*@
var maxLevelForSitemap = String.IsNullOrEmpty(Parameter.MaxLevelForSitemap) ? 4 : int.Parse(Parameter.MaxLevelForSitemap);
@*Select visible children *@ @* Select visible children *@
var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap); var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
@*If any items are returned, render a list *@ @* If any items are returned, render a list *@
if (items.Any()) { if (items.Any())
<ul> {
@foreach (var item in items) { <ul>
<li class="level-@item.Level"> @foreach (var item in items)
<a href="@item.Url">@item.Name</a> {
<li class="level-@item.Level">
<a href="@item.Url">@item.Name</a>
@*Run the traverse helper again *@ @*Run the traverse helper again *@
@traverse(item) @traverse(item)
</li> </li>
} }
</ul> </ul>
} }
} }