condition statement based on content's published state... published vs not published.
Hello,
Im new to Umbraco, so this might seem like a simple question. thank you in advance.
I would like to have a condition statement that renders a loop if the content is published, and if there is no content for that document type published it would render a message.
The syntax for the statement is pretty straightforward, I just can't find the proper vocabulary to form the condition.
here is my code... waiting for the condition. Thank you for you time.
@if (){
foreach (var item in Model.Content.Children(x=> x.IsVisible())){
<div class='CareerCard'>
<h1>@item.GetPropertyValue("jobTitle")</h1>
@item.GetPropertyValue("jobDiscription")
<hr>
@item.GetPropertyValue("howToApplyText")
</div>
}
}else{
<p>There are currently no opportunities availible. Please check back at another time.</p>
}
condition statement based on content's published state... published vs not published.
Hello,
Im new to Umbraco, so this might seem like a simple question. thank you in advance.
I would like to have a condition statement that renders a loop if the content is published, and if there is no content for that document type published it would render a message.
The syntax for the statement is pretty straightforward, I just can't find the proper vocabulary to form the condition.
here is my code... waiting for the condition. Thank you for you time.
I think if Model.Content.Children.Any() should do it. The PublishedContent API you are using will never contain unpublished items.
Actually you will need to add your condition so Model.Content.Children.Any(x => x.IsVisible())
was this statement listed anywhere in the documentation? I seem to be having trouble finding information on what should be pretty basic.
Not exactly, it is normal C#. The Any() method comes from Linq and the "filter" is a C# lambda expression
Good to know... That did the trick.
is working on a reply...