Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andrew Neely 4 posts 24 karma points
    May 21, 2013 @ 18:14
    Andrew Neely
    0

    How to Filter by a Dropdown List Multiple

    I am running Umbraco 4.0.3

    I have created a custom data type, called DepartmentDropdown, based on the dropdown list multiple type.  The  prevalues are:

     

    • All Departments  39
    • Department 1      40
    • Department 2      41
    • Department 3      42

     

    I have a Document Type called Event Item, that holds upcoming events called EVENT ITEM.  This document type has a property called "departments" that is of the DepartmentDropdown data type.

    The purpose of this property is to allow me to filter events by department.  I am required to allow a single event to pertain to zero, one, or more than one department, such that "event A" could be for "department 1" and "department 2"  or have no association at all.

    I have created an existing XSLT macro which lists all events.  I modified it to pass in a parameter called @department, so I can embed the macro in several templates, and just specify the department whose events it should show.

    In this XSLT macro, I need to select those nodes that are of the EVENT ITEM type AND are of the particular department.  I don't think I'm doing it right.

    I have spent two days looking for the syntax in XSLT to pull this off, but I can't find it.  My first attempt doesn't work. Here it is. 

     

     

        select="$currentPage//node[@nodeTypeAlias='Event Item']
                                                [@department =data[@alias='departments']]" />

    Any suggestions?

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 21, 2013 @ 19:02
    Tom Fulton
    0

    Hi Andrew,

    I think you're on the right track but just have a small syntax issue.  I assume you have a variable defined that pulls in the department parameter?  If so you can access that like:  $department, so this should work:

     

     select="$currentPage//node[@nodeTypeAlias='Event Item'][data[@alias='departments'] = $department]" />

    And since your departments field can contain multiple values, you can try the contains() function:

     select="$currentPage//node[@nodeTypeAlias='Event Item'][contains(data[@alias='departments'], $department])" />

    If you're still having trouble - make sure your $department variable is getting populated from your parameter by writing it out:  <xsl:value-of select="$department" />.  Also, is your doctype alias 'Event Item' or 'EventItem'?  Usually the aliases don't have spaces (at least in newer versions).  Lastly, check if it works without the second conditional (ie just the nodeTypeAlias check).

    Hope this helps,
    Tom 

     

Please Sign in or register to post replies

Write your reply to:

Draft