diff --git a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
index 7606b6a..204fb80 100644
--- a/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
+++ b/app/Umbraco/Umbraco.Archetype/Extensions/HtmlHelperExtensions.cs
@@ -12,6 +12,103 @@ namespace Archetype.Extensions
///
public static class HtmlHelperExtensions
{
+ ///
+ /// Renders the partials based on the model, partial path and given viewdata dictionary.
+ ///
+ /// The HTML helper.
+ /// The archetype model.
+ /// The partial path.
+ /// The view data dictionary.
+ ///
+ private static IHtmlString _renderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
+ {
+ var sb = new StringBuilder();
+
+ foreach (var fieldsetModel in archetypeModel)
+ {
+ sb.AppendLine(_renderPartial(htmlHelper, fieldsetModel, partialPath, viewDataDictionary).ToString());
+ }
+
+ return new HtmlString(sb.ToString());
+ }
+
+ ///
+ /// Renders the fieldset partial
+ ///
+ /// The HTML helper.
+ ///
+ /// The partial path.
+ /// The view data dictionary.
+ ///
+ private static IHtmlString _renderPartial(HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary)
+ {
+ var context = HttpContext.Current;
+
+ if (fieldsetModel == null || context == null)
+ {
+ return new HtmlString("");
+ }
+
+ var sb = new StringBuilder();
+
+ //default
+ var pathToPartials = "~/Views/Partials/Archetype/";
+
+ if (!string.IsNullOrEmpty(partialPath))
+ {
+ pathToPartials = partialPath;
+ }
+
+ var partial = string.Format("{0}{1}.cshtml", pathToPartials, fieldsetModel.Alias);
+
+ if (System.IO.File.Exists(context.Server.MapPath(partial)))
+ {
+ sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
+ }
+ else
+ {
+ LogHelper.Info(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
+ }
+
+ return new HtmlString(sb.ToString());
+ }
+
+ ///
+ /// Renders a single archtype partial from a fieldset
+ ///
+ /// The HTML helper.
+ /// The fieldset model.
+ ///
+ public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel)
+ {
+ return _renderPartial(htmlHelper, fieldsetModel, null, null);
+ }
+
+ ///
+ /// Renders the archetype partial.
+ ///
+ /// The HTML helper.
+ /// The fieldset model.
+ /// The partial view.
+ ///
+ public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialView)
+ {
+ return _renderPartial(htmlHelper, fieldsetModel, partialView, null);
+ }
+
+ ///
+ /// Renders the archetype partial.
+ ///
+ /// The HTML helper.
+ /// The fieldset model.
+ /// The partial view.
+ /// The view data dictionary.
+ ///
+ public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialView, ViewDataDictionary viewDataDictionary)
+ {
+ return _renderPartial(htmlHelper, fieldsetModel, partialView, viewDataDictionary);
+ }
+
///
/// Renders the archetype partials.
///
@@ -20,7 +117,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel)
{
- return RenderPartials(htmlHelper, archetypeModel, null, null);
+ return _renderPartials(htmlHelper, archetypeModel, null, null);
}
///
@@ -32,7 +129,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath)
{
- return RenderPartials(htmlHelper, archetypeModel, partialPath, null);
+ return _renderPartials(htmlHelper, archetypeModel, partialPath, null);
}
///
@@ -44,7 +141,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, ViewDataDictionary viewDataDictionary)
{
- return RenderPartials(htmlHelper, archetypeModel, null, viewDataDictionary);
+ return _renderPartials(htmlHelper, archetypeModel, null, viewDataDictionary);
}
///
@@ -57,49 +154,7 @@ namespace Archetype.Extensions
///
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
{
- return htmlHelper.RenderPartials(archetypeModel, partialPath, viewDataDictionary);
- }
-
- ///
- /// Renders the partials based on the model, partial path and given viewdata dictionary.
- ///
- /// The HTML helper.
- /// The archetype model.
- /// The partial path.
- /// The view data dictionary.
- ///
- private static IHtmlString RenderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
- {
- var context = HttpContext.Current;
-
- if (archetypeModel == null || context == null)
- {
- return new HtmlString("");
- }
-
- var sb = new StringBuilder();
-
- var pathToPartials = "~/Views/Partials/Archetype/";
- if (!string.IsNullOrEmpty(partialPath))
- {
- pathToPartials = partialPath;
- }
-
- foreach (var fieldsetModel in archetypeModel)
- {
- var partial = pathToPartials + fieldsetModel.Alias + ".cshtml";
-
- if (System.IO.File.Exists(context.Server.MapPath(partial)))
- {
- sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
- }
- else
- {
- LogHelper.Info(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
- }
- }
-
- return new HtmlString(sb.ToString());
+ return htmlHelper._renderPartials(archetypeModel, partialPath, viewDataDictionary);
}
}
}
\ No newline at end of file
diff --git a/app/directives/archetypecustomview.js b/app/directives/archetypecustomview.js
index d6719aa..3cc83c5 100644
--- a/app/directives/archetypecustomview.js
+++ b/app/directives/archetypecustomview.js
@@ -1,7 +1,7 @@
angular.module("umbraco.directives").directive('archetypeCustomView', function ($compile, $http) {
var linker = function (scope, element, attrs) {
- var view = "/App_plugins/Archetype/views/archetype.default.html";
+ var view = "../App_plugins/Archetype/views/archetype.default.html";
if(scope.model.config.customViewPath) {
view = scope.model.config.customViewPath;
}