Copied to clipboard

Flag this post as spam?

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


  • FarmFreshCode 225 posts 422 karma points
    Dec 18, 2013 @ 17:54
    FarmFreshCode
    0

    XSLT filter results if property includes a value

    I have a directory of people with profiles. Inside the profile users are able to select (checkboxes) which departments they belong to. Some have 1, some have many. Currently I filter which results I want to display on a specific page by writing a WHOLE BUNCH of lines like this:

    <filter id="8576" property="facultyDepartment" value="Public Administration" />
    <
    filter id="8576" property="facultyDepartment" value="Public Administration,PA" />
    <filter id="8576" property="facultyDepartment" value="Public Administration,PA,EM" />
    <
    filter id="8576" property="facultyDepartment" value="Public Administration,PA,NM" />

    This is NOT a great way of doing it because I have to list every possible combination of departments in order for it to work correctly.

    what I need is a statement that says:

    If on nodeID="8576" and property="facultyDepartment" CONTAINS THE VALUE="Public Administration"  AT ALL.

    A statement like that would save me from having to figure out all of the possible combinations and allow me to say if this value is INCLUDED in the profile then display it on this page.

    Any help anyone could provide would be MUCH appreciated!!
    Thank you in advance.

     


  • san 30 posts 51 karma points
    Dec 18, 2013 @ 18:01
    san
    0

    Hi,

    when I am adding article photo to my content page ..In my browser I am not able to see image ..

    my window appears with the text as /media/1015/lighthouse.jpg

    can you please help me . thanks.

    Regards Tanya

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 18, 2013 @ 18:37
    Dennis Aaen
    0

    Hi Tanya,

    I think that you should start a new topic and describe your problem, as you did in your post above and give the topic a good headline 

    By creating a new topic I think that you will get the chance to get more useful answers. Another good thing is to share the code you have so far if is possible and not business critical. By doing this people have better opptunities to see your code and then help you to find the right solution.

    /Dennis

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 03, 2014 @ 15:25
    Lee Kelleher
    0

    @FarmFreshCode - did you figure this out already?

    If not, you could try this...

    <xsl:if test="filter[@id = '8576' and property = 'facultyDepartment' and contains(value, 'Public Administration')]">
        <!-- display what you want here -->
    </xsl:if>
    

    If this isn't what you are after, then I'd need to see a snippet of your current XSLT for it to make more sense.

    Cheers,
    - Lee

  • FarmFreshCode 225 posts 422 karma points
    Jan 06, 2014 @ 13:47
    FarmFreshCode
    0

    Hi Lee! Thanks for responding.

    The probelm I would have with that kind of solution is that it would require me to write out the page template stuff for each "test".  Let's say I have 20 departments, I would have to write the same exact thing to replace your "<!-- display what you want here -->" 20 times... and should I want to make a change to the page layout I would then have to update that 20 times as well... if that turns out to be the end solution ok, but it's not as optimal as I would like.

    Here is a snippet of my code:

    <!-- Build an XML variable with all the filters available -->
    <xsl:variable name="filterProxy">
            <filter id="6624" property="facultyResearchInterests" value="health" />
            <filter id="6623" property="facultyDepartment" value="Social Work" />
     
      <!-- Landing Pages -->
            <filter id="5840" property="facultyDepartment" value="Health Management and Informatics" />
            <filter id="5840" property="facultyDepartment" value="Health Management and Informatics,International Committee" />
      
            <filter id="4987" property="facultyDepartment" value="Communication Sciences and Disorders" />
            <filter id="4987" property="facultyDepartment" value="Communication Sciences and Disorders,Communication Disorders Clinic" />
            <filter id="4987" property="facultyDepartment" value="Communication Sciences and Disorders,FAAST Assistive Technology Center" />

            <filter id="6941" property="facultyDepartment" value="Criminal Justice" />
            <filter id="6941" property="facultyDepartment" value="Criminal Justice,Dean's Office,Undergraduate Student Services,Instructional Support and Technology,International Committee" />
     
            <filter id="6943" property="facultyDepartment" value="Legal Studies" />
     
            <filter id="6944" property="facultyDepartment" value="Public Administration" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,Center for Public and Nonprofit Management " />
            <filter id="6944" property="facultyDepartment" value="Public Administration,Dean's Office" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,PA" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,NM" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,URP" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,RA" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,EM" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,PA,EM" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,PA,NM" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,PA,NM,Dean's Office" />
            <filter id="6944" property="facultyDepartment" value="Public Administration,PA,EM" />
            <filter id="8576" property="facultyDepartment" value="Public Administration,PA" />
            <filter id="8576" property="facultyDepartment" value="Public Administration,PA,EM" />
            <filter id="8576" property="facultyDepartment" value="Public Administration,PA,NM" />
            <filter id="8576" property="facultyDepartment" value="Public Administration,PA,NM,Dean's Office" />
            <filter id="8577" property="facultyDepartment" value="Public Administration,NM" />
            <filter id="8577" property="facultyDepartment" value="Public Administration,PA,NM,Dean's Office" />
            <filter id="8578" property="facultyDepartment" value="Public Administration,URP" />
            <filter id="8579" property="facultyDepartment" value="Public Administration,RA" />
            <filter id="8580" property="facultyDepartment" value="Public Administration,EM" />
            <filter id="8580" property="facultyDepartment" value="Public Administration,PA,EM" />
    </xsl:variable>

    <!-- Grab the filter that applies to this page -->
    <xsl:variable name="facultyFilter" select="msxml:node-set($filterProxy)/filter[@id = $currentPage/@id]" />
     
    <!-- Grab the root node to do lookups under -->
    <xsl:variable name="rootNode" select="umbraco.library:GetXmlNodeById(6394)" />

     
    <!-- END PAGE STUFF -->
     
      <ul>
        <xsl:for-each select="$rootNode/FacultyProfile[*[name() = $facultyFilter/@property] = $facultyFilter/@value] | $rootNode/FacultyProfile[not($facultyFilter)]">
        <xsl:sort select="facultyLastName"  order="ascending" />
     
    <xsl:variable name="mydatatype" select="umbraco.library:GetPreValues('1637')"/>
    <xsl:variable name="myproperty" select="facultyDepartment"/>
     
    <xsl:variable name="myID">
      <xsl:for-each select="$mydatatype//preValue[contains($myproperty,.)]">
        <xsl:text> </xsl:text><xsl:value-of select="@id"/>
      </xsl:for-each>
    </xsl:variable>

      <li class='item {$myID}' style="margin:0px;padding:0px;list-style:none;"><!--MAKE THIS DYNAMIC WITH DEPARTMENT-->
    <div id="cohpa-directory-wrapper" class="tempDirectory_container">
        <div class="tempDirectory_middle">
           <div id="cohpa-directory-name">
              <a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}" target="_parent"><xsl:value-of select="facultyFirstName"/>&nbsp;<xsl:value-of select="facultyLastName"/>
              </a>
            </div>
         
            <xsl:if test="string-length(facultyJobTitle) > 0"> 
              <xsl:value-of select="umbraco.library:Replace(facultyJobTitle, ',', ', ')" disable-output-escaping="yes"/><BR/>
            </xsl:if>

            <xsl:if test="string-length(facultyDepartment) > 0">         
              <xsl:value-of select="umbraco.library:Replace(facultyDepartment, ',', ', ')" disable-output-escaping="yes"/><BR/>    
           </xsl:if> 
        </div>   
        </div>
      </li>
    </xsl:for-each> 
      </ul>

    You can see how writing out all of the combinations of filter properties is a pain.

  • FarmFreshCode 225 posts 422 karma points
    Jan 14, 2014 @ 14:04
    FarmFreshCode
    0

    Still would love some help on this topic.

Please Sign in or register to post replies

Write your reply to:

Draft