/// <summary> /// Updates the selection from page parameters if there is a page parameter for the selection /// </summary> /// <param name="selection">The selection.</param> /// <param name="rockBlock">The rock block.</param> /// <returns></returns> public string UpdateSelectionFromPageParameters( string selection, Rock.Web.UI.RockBlock rockBlock ) { if ( !string.IsNullOrWhiteSpace( selection ) ) { var values = JsonConvert.DeserializeObject<List<string>>( selection ); // selection list is either "FieldName, Comparision, Value(s)" or "FieldName, Value(s)" if ( values.Count == 3 ) { var pageParamValue = rockBlock.PageParameter( values[0] ); if ( !string.IsNullOrEmpty( pageParamValue ) ) { values[2] = pageParamValue; return values.ToJson(); } } else if ( values.Count == 2 ) { var pageParamValue = rockBlock.PageParameter( values[0] ); if ( !string.IsNullOrEmpty( pageParamValue ) ) { values[1] = pageParamValue; return values.ToJson(); } } } return selection; }
/// <summary> /// Updates the selection from page parameters. /// </summary> /// <param name="selection">The selection.</param> /// <param name="rockBlock">The rock block.</param> /// <returns></returns> public string UpdateSelectionFromPageParameters( string selection, Rock.Web.UI.RockBlock rockBlock ) { if ( !string.IsNullOrWhiteSpace( selection ) ) { string[] selectionValues = selection.Split( '|' ); if ( selectionValues.Length >= 1 ) { var campusId = rockBlock.PageParameter( "CampusId" ).AsIntegerOrNull(); if ( campusId == null ) { var campusEntity = rockBlock.ContextEntity<Campus>(); if ( campusEntity != null ) { campusId = campusEntity.Id; } } if ( campusId.HasValue ) { var selectedCampus = CampusCache.Read( campusId.Value ); if ( selectedCampus != null ) { selectionValues[0] = selectedCampus.Guid.ToString(); return selectionValues.ToList().AsDelimited( "|" ); } } } } return selection; }