Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rearranged field rendering for better fit with Sitecore MVC
- Loading branch information
Kern Herskind Nightingale
committed
Jan 7, 2013
1 parent
f61e68a
commit 6f5d28e
Showing
10 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ obj/ | |
_ReSharper*/ | ||
[Tt]est[Rr]esult* | ||
lib/*.dll | ||
BuiltFiles_Debug.txt | ||
BuiltFiles_Debug.txt | ||
_Re[s|S]harper*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Web; | ||
using Herskind.Model.Helper.FieldTypes; | ||
using Sitecore.Data.Fields; | ||
using Sitecore.Data.Items; | ||
using Sitecore.Web.UI.WebControls; | ||
|
||
namespace Herskind.Model.Helper.Mvc | ||
{ | ||
public static class FieldExtensions | ||
{ | ||
public static HtmlString Render(this IFieldWrapper fieldWrapper) | ||
{ | ||
return new HtmlString(fieldWrapper.RenderField()); | ||
} | ||
public static HtmlString Render(this IDateFieldWrapper fieldWrapper, string dateFormat) | ||
{ | ||
return new HtmlString(fieldWrapper.RenderField("format=" + dateFormat)); | ||
} | ||
public static HtmlString Render(this IImageFieldWrapper fieldWrapper, int width, int height, bool crop) | ||
{ | ||
return fieldWrapper.Render(width, height, crop, ""); | ||
} | ||
public static HtmlString Render(this IImageFieldWrapper fieldWrapper, int width, int height, bool crop, string cssClass) | ||
{ | ||
return new HtmlString(fieldWrapper.RenderField(string.Format("w={0}&h={1}{2}&class={3}", width, height, crop ? "&crop=1" : "", cssClass))); | ||
} | ||
|
||
public static HtmlString RenderAroundHtml(this IFieldWrapper fieldWrapper, string innerHtml) | ||
{ | ||
var fieldRenderer = new FieldRenderer | ||
{ | ||
Item = ((Field)fieldWrapper.Original).Item, | ||
FieldName = ((Field)fieldWrapper.Original).Key | ||
}; | ||
|
||
|
||
var result = fieldRenderer.RenderField(); | ||
|
||
return new HtmlString(result.FirstPart + innerHtml + result.LastPart); | ||
} | ||
} | ||
} |