BV Commerce Forum
»
BV Commerce Support
»
Development
»
Here is code that can isolate XML values from a single Type Property field for use in templates.
Rank: Member
Joined: 4/3/2007(UTC) Posts: 56
|
In our case we wanted the author name displayed with each book in content blocks, product page, and category pages. We also wanted fields for flash video paths and a field for program air dates.
This works if you create one type property and designate only that type property as visible to drop-shippers.
You can then populate that one type property on the product page with XML code in the text box. For example enter: <customfields><authorname>Sample Name</authorname><videopath>Sample Video Path</videopath></customfields>
Here is the code: (modified version of code provided by the forum about a year ago to include XML parsing)
Imports BVSoftware.Bvc5.Core Imports System.Collections.ObjectModel Imports System Imports System.Xml Imports System.IO
'Author Display Name Dim adnid As String = LocalProduct.ProductTypeId Dim productTypePropertiesValues As New Collection(Of String) Dim props As Collections.Generic.List(Of Catalog.ProductProperty) = Catalog.ProductType.FindPropertiesForType(adnid) Dim sb As New StringBuilder() Dim xmlsb As New StringBuilder()
xmlsb.Append("<div class=""authorname"">") For Each prop As Catalog.ProductProperty In props productTypePropertiesValues.Add(Catalog.InternalProduct.GetPropertyValue(LocalProduct.Bvin, prop.Bvin)) Next
For i As Integer = 0 To (props.Count - 1) If props(i).DisplayToDropShipper Then
Dim currentValue As String = Catalog.ProductProperty.GetProductTypePropertyValue(props(i), productTypePropertiesValues(i)) ' If text property is empty, do not display If (props(i).TypeCode = Catalog.ProductPropertyType.TextField) AndAlso (currentValue = String.Empty) Then Continue For End If If currentValue <> String.Empty Then sb.Append(currentValue) End If End If
Next Try
Dim XMLText As New XmlTextReader(New StringReader(sb.ToString)) While (XMLText.Read()) If (XMLText.LocalName.Equals("authorname")) Then xmlsb.Append(XMLText.ReadElementString("authorname")) End If
End While
Catch ex As Exception
End Try
xmlsb.Append("</div>")
Me.authordisplayname.Text = xmlsb.ToString
'End Author Display Name
|
|
|
|
Rank: Member
Joined: 1/10/2005(UTC) Posts: 714
Thanks: 14 times Was thanked: 1 time(s) in 1 post(s)
|
do you have a site that uses this?
|
|
|
|
Rank: Member
Joined: 4/3/2007(UTC) Posts: 56
|
www.dhp.org uses it to display author name on product templates, category templates, and in a content block on the home page
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.