Iam really new to Umbraco but have used the MVC pattern with razord syntax before.
What i iam trying to do is to list all my properties in a list. I have added serveral page's created with a specified document type that i want to loop to get all propertie values.
Im trying to achive this with a partial view macro, but cant get it to work.
Alias of Document type: ExtremeNewsItem Calling Macro in Partial View: @Umbraco.RenderMacro("ExtremeStartpageList")
Dependent upon the version, you may need to call @item.Url(), or item.Url, or item.NiceUrl() or item.NiceUrl. Also it is odd, but the Umbraco Library is not a capital, so @library.
I think you code looks to be OK, in terms of getting what you require, it just seems some of the "Umbraco" sensitive points need a tweek.
There are many ways to make Umbraco work, with a little more time you will begin to feel more comfortable.
Ok if V6 Mvc, it would be easier to know what error you are getting.
It looks to me that maybe you could use as just a partial? If you first get to work as a partial, then if you need as a macro, at least you know the code is working.
For the partial, call @Html.Partial("nameOfPartial") from the view.
In partial view
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<ul>
@foreach (var item in CurrentPage.Children.OrderBy("ExtremeDatePosted")) moved to dynamic CurrentPage, or use Model.Content.Children
{
<li>
<span>@item.ExtremeDatePosted</span> using dynamic @CurrentPage or @Model.Content.GetPropertyValue("ExtremeDatePosted")
Just some thoughts, your extremeStartPage template needs to be assigned to your documentType, go to Content Section and then run from the properties tab, where you will see the template type listed, then under is the link to the page, there is a link and an alternative link.
As mentioned previously, your fields, when call need to begin with capital letter, so you have called pageTitle, as per the alias, but it must be PageTitle.
First just make something simple work, document type attached to template, call a layout in this, and call a simple textstring field.
If it would be of more use, there is a good sample site that Jeroen put together for DAMP, it would be worth downloading and looking at the structure.
Razor Partial View Macro (v. 6)
Hi!
Iam really new to Umbraco but have used the MVC pattern with razord syntax before.
What i iam trying to do is to list all my properties in a list.
I have added serveral page's created with a specified document type that i want to loop to get all propertie values.
Im trying to achive this with a partial view macro, but cant get it to work.
Alias of Document type: ExtremeNewsItem
Calling Macro in Partial View: @Umbraco.RenderMacro("ExtremeStartpageList")
This is my properties i want to loop:
This is how i want the macro:
Hi Stefan
Not sure there is enough here to give you a full answer - would need to know Umbraco version ie 4.11 etc and if you are using in Webforms or Mvc mode.
But just some general points -
should be Model.Children.OrderBy - but your document alias should be as written - ie ExtremeDatePosted, if first letter is capital, then it must be.
When you call a field, even thought the alias first letter is not a Capital, the call must be a Capital, therefore "ExtremeDatePosted"
Dependent upon the version, you may need to call @item.Url(), or item.Url, or item.NiceUrl() or item.NiceUrl. Also it is odd, but the Umbraco Library is not a capital, so @library.
I think you code looks to be OK, in terms of getting what you require, it just seems some of the "Umbraco" sensitive points need a tweek.
There are many ways to make Umbraco work, with a little more time you will begin to feel more comfortable.
Hope it helps G
Hi & Thanks for your response gary.
I have changed the code but i still can't get the macro to render. I use Umbraco 6 with MVC.
Hi
Ok if V6 Mvc, it would be easier to know what error you are getting.
It looks to me that maybe you could use as just a partial? If you first get to work as a partial, then if you need as a macro, at least you know the code is working.
For the partial, call @Html.Partial("nameOfPartial") from the view.
In partial view
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<ul>
@foreach (var item in CurrentPage.Children.OrderBy("ExtremeDatePosted")) moved to dynamic CurrentPage, or use Model.Content.Children
{
<li>
<span>@item.ExtremeDatePosted</span> using dynamic @CurrentPage or @Model.Content.GetPropertyValue("ExtremeDatePosted")
<br />
<a href="@item.Url()">@Umbraco.Truncate(ExtremeNewsHeadline,100)</a>
</li>
}
</ul>
If you use Model.Content. you will get Intellisense in VS, or WebMatrix, if this helps, but it doesn't show for dynamic @CurrentPage
Ok, if you can get that to run in a partial - you will be heading in the right direction.
Regards G
I have tryed and tryed.
I cant even run this in my partial view, simple text works good in partial view.
Ok ill try to ask again.
This is my layout three:
ExtremeStartpageLayout
- ExtremeStartpageContent (Partial: _ExtremeNewsList.cshtml)
When i use this i got no error, but i also doesent get any thing looping in the partial view, what am i doing wrong?
ExtremeStartpageLayout:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>@Umbraco.Field("pageTitle")</title>
<link rel="stylesheet" type="text/css" href="/css/reset.css">
<link rel="stylesheet" type="text/css" href="/css/ExtremeNews.css">
</head>
<body>
<div id="pageWrapper">
<header>
<div id="leftTopImage"></div>
<div id="logoType">
<img src="/media/48943/logotype.jpg" alt="logotype." />
</div>
</header>
<div id="contentWrapper">
@RenderSection("Content", true)
</div>
</div>
</body>
</html>
ExtremeStartpageContent
_ExtremeNewsList
Hi Stefan
First thing is you need an @RenderBody() in your layout page, but I am surprised you did not get an error for this. Is anything at all displaying?
G
Just some thoughts, your extremeStartPage template needs to be assigned to your documentType, go to Content Section and then run from the properties tab, where you will see the template type listed, then under is the link to the page, there is a link and an alternative link.
As mentioned previously, your fields, when call need to begin with capital letter, so you have called pageTitle, as per the alias, but it must be PageTitle.
First just make something simple work, document type attached to template, call a layout in this, and call a simple textstring field.
If it would be of more use, there is a good sample site that Jeroen put together for DAMP, it would be worth downloading and looking at the structure.
http://24days.in/umbraco/2012/damp-gallery/
It is on that link and can open as a VS project, this again may help you in relating the MVC with the Umbraco SetUp.
Hope this can help you
G
is working on a reply...