var topNav = @umbraco.library.RenderMacroContent("", Model.Id);
var mainNav = @umbraco.library.RenderMacroContent("", Model.Id);
}
This is giving me the content of the HomePage item.
I already used this in a previous version of umbraco (4.7.2) and it worked. I guess the way to do it is different in V6 but I can't find out the solution.
ContentPage is not a partial view, it's a template and SubPage as well: MasterPage is the MasterPageFile of SubPage SubPage is the MasterPageFile of ContentPage
Sorry this might sound stupid. Why are you trying to use templates with MVC?. I think thats where you might be going wrong. When you change the settings from WebForms to MVC. With in the templates folder, those are now Views.
Under the developer tab click on the PartialViewMacroFiles and create one called ContentPage.
Put your ContentPage markup in here.
In your SubPage (Template/View) call the ContentPage using @Html.RenderPartial("ContentPage");
This should now render then content from the ContentPage. Hope this helps.
The fact is that in the SubPage template, I have a piece of HTML that is the same for each content (ContentPage, SpecificContentPage, MoreSpecificContentPage ...) This html section contains the navigation menus, logo and the title and short description of each ContentPage.
The idea is to retrieve the "@Model.title" and "@Model.ShortDesc" of the ContentPage and display them in the common section in the SubPage template and display the rest of the content (of ContentPage) below this commom section. (you still follow me?)
I continued using the template because I come from a 4.7.2 umbraco version so it was natural for me. I'm not used yet to the partial views. Do you have a good link to learn about the partial views?
Thanks.
Juste made a test, I got this error: Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel>' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel>' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 1: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Line 2:
Line 3: @Html.RenderPartial("TopNavigationPV")
Here we go, this will tell you all about it :D. http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx. About half way down. Partial Views. All they are doing is rendering html into the part of the page you put the partial. Do you have visual studio?. Also if you i am gonna post on charlesafford.com this weekend about creating your first surface controller. (You need this for Umbraco MVC).
Umbraco V6 Rendering page problem
Hi,
I'm trying to display the content of a page in a parent template but I can't make it work.
Here is my hierarchy:
For the templates it works like this:
I would like to display the content of ContentPage in the SubPage template.
Here is the code I implemented in the SubPage template:
This is giving me the content of the HomePage item.
I already used this in a previous version of umbraco (4.7.2) and it worked. I guess the way to do it is different in V6 but I can't find out the solution.
Any help is welcome.
Thanks in advance,
Dams
I know I should use CurrentPage but if I try something like this
<pre>
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@inherits System.Web.WebPages.WebPage
@{
var currentpage = CurrentPage;
}
</pre>
I absolutely need to inherits System.Web.WebPages.WebPage and CurrentPage is not recognized
Hi, Are you using Razor/MVC as apposed to webforms?
Is ContentPage then a partial view and the SubPage a view?
Thanks.
Charlie.
Hi Charlie,
I'm using the Mvc rendering engine.
ContentPage is not a partial view, it's a template and SubPage as well:
MasterPage is the MasterPageFile of SubPage
SubPage is the MasterPageFile of ContentPage
Thanks
Sorry this might sound stupid. Why are you trying to use templates with MVC?. Dont worry i see what you are refering to.
Sorry this might sound stupid. Why are you trying to use templates with MVC?. I think thats where you might be going wrong. When you change the settings from WebForms to MVC. With in the templates folder, those are now Views.
Under the developer tab click on the PartialViewMacroFiles and create one called ContentPage.
Put your ContentPage markup in here.
In your SubPage (Template/View) call the ContentPage using @Html.RenderPartial("ContentPage");
This should now render then content from the ContentPage. Hope this helps.
Let me know :).
Charlie
I understand your point of view and I agree ;-)
The fact is that in the SubPage template, I have a piece of HTML that is the same for each content (ContentPage, SpecificContentPage, MoreSpecificContentPage ...)
This html section contains the navigation menus, logo and the title and short description of each ContentPage.
The idea is to retrieve the "@Model.title" and "@Model.ShortDesc" of the ContentPage and display them in the common section in the SubPage template and display the rest of the content (of ContentPage) below this commom section. (you still follow me?)
I continued using the template because I come from a 4.7.2 umbraco version so it was natural for me.
I'm not used yet to the partial views. Do you have a good link to learn about the partial views?
Thanks.
Juste made a test, I got this error:
Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel>' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel>' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 1: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage Line 2: Line 3: @Html.RenderPartial("TopNavigationPV")
What have you got at the top of TopNavigationPV?
Here we go, this will tell you all about it :D. http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx. About half way down. Partial Views. All they are doing is rendering html into the part of the page you put the partial. Do you have visual studio?. Also if you i am gonna post on charlesafford.com this weekend about creating your first surface controller. (You need this for Umbraco MVC).
Hi Charles,
Sorry for late answers!
Here is the content of my TopNavigationPV.cshtml
<pre>
@inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>
<ul class="topnav">
<li>@Model.AncestorOrSelf(1).headerText</li>
@foreach(var item in @Model.AncestorOrSelf(1).topNav)
{
<li><a href="@item.Url">@item.Name</a></li>
}
@{
umbraco.MacroEngines.DynamicNode contentRoot = new umbraco.MacroEngines.DynamicNode(-1);
}
<li class="lang"><a href="#" class="currentLang">@Model.AncestorOrSelf(1).languageCaption</a>
<ul>
@foreach(var lang in contentRoot.ChildrenAsList)
{
if(lang.Id != Model.AncestorOrSelf(1).Id)
{
<li><a href="@lang.Url">@lang.Name</a></li>
}
}
</ul>
</li>
</ul>
</pre>
Unfortunately I don't have VS ... maybe it would be helpfull :P
Thanks for your help!
Ok, try replacing:
@inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>
WITH
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
is working on a reply...