Friday, November 20, 2015

Evanced Code for Dynamically Pulling Events in ASPX

I can't take the credit for this one - this was all our IT department bailing me out. I needed to dynamically grab the events through with the XML or JSON feed so I could display them on our OPAC. I can do the front-end piece and if this was PHP no problem, but it was much faster to toss pride away and just ask for help.

This code assumes you only have on URL (mURL) - if you have mutliple locations you'll need to create a dynamic solution. This was a pretty rapid test, but we will be adding in dynamic code. Once we do, I'll update the page accordingly.

<script runat="server">
        Sub Page_Load()
            If Not Page.IsPostBack Then
                Dim mURL As String

                mURL = ""

                Dim xmlDoc As New XmlDocument()
                Dim nodes As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("/event/item")
                Dim pTitle As String = ""
                Dim pTitleCk As String = ""
                Dim pDate As String = ""
                Dim pTime As String = ""
                Dim pEndDate As String = ""
                Dim pDescription As String = ""
                Dim pLocation As String = ""
                Dim pLibrary As String = ""
                Dim pLink As String = ""
                Dim intCount As Integer = 0
                Dim pTest as String

                For Each node As XmlNode In nodes

                    pTitle = node.SelectSingleNode("title").InnerText
                    pDate = node.SelectSingleNode("date").InnerText
                    pTime = node.SelectSingleNode("time").InnerText
                    pEndDate = node.SelectSingleNode("enddate").InnerText
                    pDescription = node.SelectSingleNode("description").InnerText
                    pLocation = node.SelectSingleNode("location").InnerText
                    pLibrary = node.SelectSingleNode("library").InnerText
                    pLink = node.SelectSingleNode("link").InnerText

                    If (pTitle = pTitleCk) Then

                        'Eliminate HTML tags
                        pDescription = pDescription.Replace("<p>", "")
                        pDescription = pDescription.Replace("</p>", "")
                        pDescription = pDescription.Replace("<br>", "")

                        pTest = pTest & "<div class='event pull-left'><a class='swipebox-video' href='" & pLink & "?swipeboxVideo=1'><h2 class=''>" & pTitle & "</h2></a><div class=''>" & pDate & " (" & pTime & ")<br>" & pDescription & "</div></div>"
                        'pTest = pTest & "<div class='event pull-left'><a href='" & pLink & "'><h2 class=''>" & pTitle & "</h2></a><div class=''>" & pDate & " (" & pTime & ")<br>" & pDescription & "<a class='more-info' href='" & pLink & "'> More Info</a></div></div>"
                        'Response.Write(pDescription & "<br>" & pLibrary & ":  " & pLocation & "<br><br>")
                        '<a href='" & pLink & "'>More Info</a><br><br>")

                            intCount = intCount + 1
                          Literal1.Text = pTest 

                    End If

                    pTitleCk = pTitle

            End If
        End Sub

This is an example of the page in action:

Friday, November 13, 2015

CASE STUDY: Breadcrumbs

Breadcrumb trails on a page indicate the page's position in the site hierarchy. A user can navigate all the way up in the site hierarchy, one level at a time, by starting from the last breadcrumb in the breadcrumb trail. For complex or deep websites, the correct type of breadcrumbs are extremely helpful. There are three types of breadcrumbs: location-based, path-based, and attribute-based. Share Thurow from Marketing Land does a good job summarizing the types of breadcrumbs and when to use them. I've modified them to Library world examples.  

Location-based breadcrumbs help the user understand the websites structure by identifying your current page and linking to pages above in the hierarchy.  

Home > Services > Book Kits  
The structure is pretty obvious here. The user is on the Book Kits page that resides under Services and Services resides under Home. This type of breadcrumb supports usability, findability, and accessibility to improve the user experience. Findability is an important part of how I define User Experience and it often gets left off of many User Experience diagrams.  
User Experience Honeycomb  
User Experience Honeycomb by Peter Morville. Used with Permission.  
Path-based breadcrumbs are pointless. I'm not sure why they were ever invented, but they essentially create a trail for you of every page you've been to on the website.   

Home > Services > Book Kits > About Us > Home > Contact Us > Catalog  
There is no structure here that helps navigation. It duplicates the function of the back button, it confuses a user who might want to reference where they are in the website hierarchy compared to home, it displays a creepy tracking history trail is not helpful, and it confuses search engines by showing duplicate content links with endless variations for robots to find.  
Attribute-based is what every good e-commerce website should have implemented for filtering and faceted searching. This is the most complicated type of breadcrumb to implement correctly because with search engines it is extremely important not to portray duplicate content. So making sure you setup correct redirects (.htaccess or proxy level) to ensure the order of the filters doesn't matter is critical.  

| Fiction x | Adult x | War x | History x  
When using Attribute-based breadcrumbs it may or may not be helpful to include Location-based breadcrumbs. In the next example, I've mixed Location-based breadcrumbs and Attribute-based breadcrumbs. The first 3 items are Location-based and the last 4 are Attribute-based.  
Home > Services > Book Kits | Fiction x | Adult x | War x | History x  
Breadcrumbs aren't aiding the user significantly and taking up valuable space.  

Home Button: 1,555
First Tier: 190
Second Tier: 0

Total Users: 235,986
There is an article from Google on Structured Data and using breadcrumbs in searches which should put down all arguments about breadcrumbs being dated and pointless. They use structured data and breadcrumbs to directly impact search results allowing user to not hit the desired landing page, but navigate to a subset of that page whether it is location or attribute based. If the big G uses it to help you tailor searches better for your audience, you better get on board.   
Structured Data  
Un-Structured Data  
Having trouble finding the structure? Pay close attention to the URL.  

While the 2009 study from Jakob Nielson and Kara Pernice is ancient in regards to breadcrumb tracking, the large amount of data there is definitely one reason we still have breadcrumbs. The book Eyetracking Web Usability summarized the data and concluded that "People look at breadcrumbs 30% of the time". Now realize that number has changed over 6 years, but the study combined with Google using structured data and you have a really hard argument to discredit.