Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Apr 09, 2010 @ 18:01
    trfletch
    0

    Check if node selected in Ultimate picker is published or exists

    Hi All,

    I have an Umbraco V4.0.3 website and I am using the Ultimate picker to get data from one node displayed on the page of another, the Ultimate picker is called "recruiter". This works great apart from when someone selects a node using the Ultimate picker that is unpublished or they delete a node that is currently selected from the Ultimate pick on another node. This causes an XSLT error on the page. Basically I want to be able to check that the node selected in the Ultimate picker is published and exists otherwise do not try and display the information from it. This is the XSLT I currently have and as you can see it currently checks whether something is selected for "recruiter" using the Ultimate picker and if not then don't display the details but this does not work if a "recruiter" is selected but that Recruiter page is unpublished or has been deleted:

    <xsl:template match="/">

    <xsl:variable name="recruiter" select="umbraco.library:GetXmlNodeById($currentPage/data  [@alias='recruiter'])" />
    <xsl:for-each select="$currentPage">
    <xsl:if test="data  [@alias='recruiter'] !=''">
    <h2>
    Recruiter: <xsl:value-of select="$recruiter/@nodeName"/>
    </h2>
    </xsl:if>
    </xsl:for-each>
    <xsl:if test="$currentPage/data  [@alias='recruiter'] !=''">
     <a href="{umbraco.library:NiceUrl($currentPage/data  [@alias='recruiter'])}">
      <img class="recruiterlogo">
          <xsl:attribute name="src">
            <xsl:value-of select="umbraco.library:GetMedia($recruiter /data  [@alias='recruiterlogo'], 'false')/data [@alias='umbracoFile']" />
          </xsl:attribute>
          <xsl:attribute name="width">
            <xsl:value-of select="umbraco.library:GetMedia($recruiter  /data  [@alias='recruiterlogo'], 'false')/data [@alias='umbracoWidth']" />
          </xsl:attribute>
          <xsl:attribute name="height">
            <xsl:value-of select="umbraco.library:GetMedia($recruiter  /data  [@alias='recruiterlogo'], 'false')/data [@alias='umbracoHeight']" />
          </xsl:attribute>
          <xsl:attribute name="alt">
            <xsl:value-of select="$recruiter/@nodeName"/> logo</xsl:attribute>
        </img> 
    </a>
    </xsl:if>



    </xsl:template>
  • dandrayne 1138 posts 2262 karma points
    Apr 09, 2010 @ 18:12
    dandrayne
    0

    Hi Again

    I use this for the multiple content picker, it should work for the ultimate picker too

    <xsl:if test="not(contains(current(), 'No published item exist'))">
    <li>
    <a href="{umbraco.library:NiceUrl(current()/@id)}"><xsl:value-of select="current()/@nodeName" /></a>
    </li>
    </xsl:if>

    Dan

     

  • trfletch 598 posts 604 karma points
    Apr 09, 2010 @ 18:43
    trfletch
    0

    Thanks Dan, I was wondering about something to check for the "No published item exist" text but I wasn't sure how to go about it, I'll give that a try on Monday and let you know if I have any problems, have a good weekend.

  • trfletch 598 posts 604 karma points
    Apr 12, 2010 @ 15:23
    trfletch
    0

    Thanks again Dan, that has worked perfectly.

Please Sign in or register to post replies

Write your reply to:

Draft