Created
June 12, 2013 04:22
-
-
Save jsheely/5762817 to your computer and use it in GitHub Desktop.
Ventrian News Articles. Enable date formatter on custom properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If (layoutArray(iPtr + 1).ToUpper().StartsWith("CUSTOM:")) Then | |
Dim field As String = layoutArray(iPtr + 1).Substring(7, layoutArray(iPtr + 1).Length - 7) | |
Dim customFieldID As Integer = Null.NullInteger | |
Dim objCustomFieldSelected As New CustomFieldInfo | |
Dim isLink As Boolean = False | |
Dim objCustomFieldController As New CustomFieldController | |
Dim objCustomFields As ArrayList = objCustomFieldController.List(objArticle.ModuleID) | |
Dim maxLength As Integer = Null.NullInteger | |
Dim formatExpression As String = "" | |
If (field.IndexOf(":") <> -1) Then | |
If IsNumeric(field.Split(":")(1)) Then | |
maxLength = Convert.ToInt32(field.Split(":")(1)) | |
Else | |
maxLength = Null.NullInteger | |
formatExpression = field.Split(":")(1) | |
End If | |
field = field.Split(":")(0).ToLower() | |
End If | |
If (customFieldID = Null.NullInteger) Then | |
For Each objCustomField As CustomFieldInfo In objCustomFields | |
If (objCustomField.Name.ToLower() = field.ToLower()) Then | |
customFieldID = objCustomField.CustomFieldID | |
objCustomFieldSelected = objCustomField | |
End If | |
Next | |
End If | |
If (customFieldID <> Null.NullInteger) Then | |
Dim i As Integer = 0 | |
If (objArticle.CustomList.Contains(customFieldID)) Then | |
Dim objLiteral As New Literal | |
Dim fieldValue As String = GetFieldValue(objCustomFieldSelected, objArticle, False) | |
If (maxLength <> Null.NullInteger) Then | |
If (fieldValue.Length > maxLength) Then | |
fieldValue = fieldValue.Substring(0, maxLength) | |
End If | |
End If | |
If formatExpression <> "" Then | |
If formatExpression = "d" Then | |
formatExpression = "%" & formatExpression | |
End If | |
fieldValue = DateTime.Parse(fieldValue).ToString(formatExpression) | |
End If | |
objLiteral.Text = fieldValue.TrimStart("#"c) | |
objLiteral.EnableViewState = False | |
objPlaceHolder.Add(objLiteral) | |
i = i + 1 | |
End If | |
End If | |
Exit Select | |
End If |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment