I'm getting this error but don't know what to do with it :-o ...
Compiler Error Message: CS1929: 'PartialViewMacroModel' does not
contain a definition for 'Value' and the best extension method
overload
'PublishedElementExtensions.Value
Hi Alex,
Thanks so much for you reply. That really helped me. I have updated the code, and it works like a charm :-)
I have submitted all the code below. I'm absolutely certain that if there's something called best practice, I'm not following it but so far it's acutally functioning and as a noob that's really satisfactury.
Once again: Thanks a lot for your help.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Umbraco.Web.Models
@{
var selection = Umbraco.Content(Guid.Parse("fcd487aa-f56f-4ed0-9866-aeee978f96ba"))
.ChildrenOfType("kalenderBegivenhed")
.Where(x => x.Value<DateTime>("begivenhedDato") <= DateTime.Today)
.OrderByDescending(x => x.Value("begivenhedDato"));
var previousYear = "NoPreviousYearSetYet"; // To keep track of when the year changes.
var currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.DisplayName;
var numberOfItems = Model.GetParameterValue<int>("antalBegivenheder");
var pastEvents = Model.GetParameterValue<bool>("visTidligereBegivenheder");
var futureEvents = Model.GetParameterValue<bool>("visKommendeBegivenheder");
}
<!-- Sidebar -->
<h5 class="pb-2 font-weight-bold p-1">@Umbraco.GetDictionaryValue("Kommende koncerter")</h5>
@foreach (var item in selection.Take(numberOfItems))
{
var day = (item.Value<DateTime>("begivenhedDato").ToString("dd"));
var month = (item.Value<DateTime>("begivenhedDato").ToString("MM"));
var monthName = "";
var year = (item.Value<DateTime>("begivenhedDato").ToString("yyyy"));
var time = (item.Value<DateTime>("begivenhedDato").ToString("hh:mm"));
var location = item.Value("begivenhedAdresse");
var gMapUrl = item.Value("begivenhedGoogleMapsLink");
if(currentCulture=="Danish"){
switch (month)
{
case "01":
monthName="JAN";
break;
case "02":
monthName="FEB";
break;
case "03":
monthName="MAR";
break;
case "04":
monthName="APR";
break;
case "05":
monthName="MAJ";
break;
case "06":
monthName="JUN";
break;
case "07":
monthName="JUL";
break;
case "08":
monthName="AUG";
break;
case "09":
monthName="SEP";
break;
case "10":
monthName="OKT";
break;
case "11":
monthName="NOV";
break;
case "12":
monthName="DEC";
break;
default:
monthName="XX";
break;
}
}
else{
switch (month)
{
case "01":
monthName="JAN";
break;
case "02":
monthName="FEB";
break;
case "03":
monthName="MAR";
break;
case "04":
monthName="APR";
break;
case "05":
monthName="MAY";
break;
case "06":
monthName="JUN";
break;
case "07":
monthName="JUL";
break;
case "08":
monthName="AUG";
break;
case "09":
monthName="SEP";
break;
case "10":
monthName="OCT";
break;
case "11":
monthName="NOV";
break;
case "12":
monthName="DEC";
break;
default:
monthName="XX";
break;
}
}
<!-- År skal kun printes ved første entry -->
if (year != previousYear) { // Make header for a new year.
previousYear = year;
<h6 class="year text-light font-weight-bold p-1 border-top border-bottom">@year</h6>
}
<div class="row event pb-3">
<div class="col-2">
<span class="badge badgeDate border-left border-right">
@day<br>
<span class="badgeMonth">
@monthName
</span>
</span>
</div>
<div class="col-10 calDescription">
<div class="calInfo">
<h5 class="pl-2 eventTitle text-uppercase text-white pb-2">@item.Value("begivenhedTitel")</h5>
<p class="pl-2 eventDescription">@item.Value("begivenhedBeskrivelse")</p>
</div>
<div class="calSpecifics">
<div class="d-flex flex-row pb-2">
<i class="far fa-clock d-block px-2" aria-hidden="true"></i><span class="calTime">@time</span>
</div>
<div class="d-flex flex-row">
<i class="fas fa-location-arrow d-block px-2" aria-hidden="true"></i><a href="@gMapUrl" target="_blank" class="eventMap"><span class="calLocation">@Html.Raw(location)</span></a>
</div>
</div>
</div>
</div>
<!--<div class="divider border-bottom mb-3"></div>-->
}
1) I was actually just using the call that the query builder made. How would you make the call properly then?
2) I know the two switch cases are almost identical except for two months that in abbreviated form are spellede differently. I should probably stick to ONE switch case and make the logical decisions under the two affected months instead!?
Querying and sorting events
Hello you all, I'm very new to coding as well as Umbraco so this question probably has a very simple solution.
I'm trying to create an event macro and I want to be able to sort everything in past and future events.
I'm getting this error but don't know what to do with it :-o ...
Any help will be much appreciated.
All the best, Philip
Hi Duelil
In Umbraco 8 use Value method instead of GetPropertyValue like this:
Also, show all the code maybe there are some other errors.
Thanks,
Alex
Hi Alex, Thanks so much for you reply. That really helped me. I have updated the code, and it works like a charm :-)
I have submitted all the code below. I'm absolutely certain that if there's something called best practice, I'm not following it but so far it's acutally functioning and as a noob that's really satisfactury. Once again: Thanks a lot for your help.
Some tips: 1) it's not recommended to call the node by id -
2) looks like switch case contains the same cases, not sure that I understood what is going on :)
You are always welcome!
Hi Alex
Once again: Thank you.
1) I was actually just using the call that the query builder made. How would you make the call properly then? 2) I know the two switch cases are almost identical except for two months that in abbreviated form are spellede differently. I should probably stick to ONE switch case and make the logical decisions under the two affected months instead!?
All the best, Philip
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.