Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to create a macro to list descendants where a free text field contains certain text
The property field for ‘startDateText’ is a Textstring field which could have the following entered:
I want to create a list for any that contain ‘September’ in this field.
This is the what I have at the moment which doesn’t produce a list:
@using umbraco.MacroEngines @inherits DynamicNodeContext @{ string startToFind = Parameter.ProgrammeStart; string levelToFind = Parameter.ProgrammeLevel; var root =Model.AncestorOrSelf(1); var programmeNames = root.DescendantsOrSelf("Programme").OrderBy("programmeName").ToList(); <div> <ul class="programme-list"> @foreach(var item in programmeNames) { string[] startDateText = item.startDateText.ToString().Split(','); if ((item.level == levelToFind) && (startDateText.Contains(startToFind))) { <li> <a href="@item.Url">@item.programmeName - @item.qualificationType</a> </li> } } </ul> </div> }
Hi.
I was just wondering why you haven't used a DateTime field? Are you not making it harder for yourself? :-)
Happy easter!
Daniel
Hi Daniel,
The editor needs to be able to enter dates as specific (5 September 2015) but also as just the month and year if the exact date not yet known (September 2015) so that is why we've kept it as free text rather than the DateTime field
cheers,
Clare
Hi Clare
Then why not use a checkbox that when checked, only takes the month and year of the choosen date from a datepicker? :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Razor - how to list nodes with a certain property (where that propertys field is free text)
I'm trying to create a macro to list descendants where a free text field contains certain text
The property field for ‘startDateText’ is a Textstring field which could have the following entered:
I want to create a list for any that contain ‘September’ in this field.
This is the what I have at the moment which doesn’t produce a list:
Hi.
I was just wondering why you haven't used a DateTime field? Are you not making it harder for yourself? :-)
Happy easter!
Daniel
Hi Daniel,
The editor needs to be able to enter dates as specific (5 September 2015) but also as just the month and year if the exact date not yet known (September 2015) so that is why we've kept it as free text rather than the DateTime field
cheers,
Clare
Hi Clare
Then why not use a checkbox that when checked, only takes the month and year of the choosen date from a datepicker? :-)
Daniel
is working on a reply...