Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 13 of 13

Thread: category nav

  1. #1
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default category nav

    I have my category navigation working for the most part. For some reason though, the following code works great for the first level descendants but once I go do one of those descendents, it doesn't list what is under them or the Current Entity Name. Any suggestions?

    Code:
              <xsl:template name="navigation">
                <xsl:apply-templates select="/root/EntityHelpers/Category/Entity[EntityID = /root/Runtime/EntityID]"></xsl:apply-templates>
              </xsl:template>
    
              <xsl:template match="Entity">
                <h3><xsl:value-of select="$CurrentEntity/Name" disable-output-escaping="yes" /></h3>
                  <ul class="side-menu side-info">
                  <xsl:for-each select="/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]">
                    <li><a href="{aspdnsf:EntityLink(EntityID, SEName, $EntityName, 0, '')}" title="{Name}"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                </xsl:for-each>
                  </ul>
              </xsl:template>

  2. #2
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    I'm typing this without trying it which isn't sensible at all, but the code below might work. It uses the ParentEntityID value to find all descendent children. Keeps things simple...

    Code:
    <xsl:template match="Entity">
      <xsl:variable name="EntityID" select="EntityID"/>
      <h3><xsl:value-of select="Name" disable-output-escaping="yes" /></h3>
         <ul class="side-menu side-info">
         <xsl:for-each select="/root/EntityHelpers/Category/Entity[ParentEntityID=$EntityID]">
            <li><a href="{aspdnsf:EntityLink(EntityID, SEName, Name, 0, '')}" title="{Name}"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
         </xsl:for-each>
       </ul>
    </xsl:template>

  3. #3
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    Thanks for that post webopius. Unfortunately it doesn't for-each anything. It just returns nothing. Very strange.

  4. #4
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    Hi

    Hmm, difficult to debug through the forum but my next step would be to add in some debug diagnostic lines just to double check values of variables etc. For example, check that the EntityID is being passed correctly by including this line above or below the <h3> line:

    <xsl:value-of select="$EntityID" disable-output-escaping="yes" />

    This *should* be the parent category id.

  5. #5
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    I have gotten this partially working. Here is what I have so far.

    In my template match="/" I have the following:

    Code:
    <xsl:call-template name="navigation" />
    I then have the following outside that template:

    Code:
    <xsl:template name="navigation">
                <h3><xsl:value-of select="/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]/Name" disable-output-escaping="yes" /></h3>
                <xsl:apply-templates select="/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]"></xsl:apply-templates>
              </xsl:template>
    
              <xsl:template match="Entity">
                  <ul class="side-menu side-info">
                    <xsl:value-of select="/root/EntityHelpers/Category/Entity[ParentEntityID=EntityID]" disable-output-escaping="yes" />
                  <xsl:for-each select="/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/Runtime/CatID]">
                    <li><xsl:value-of select="Name" disable-output-escaping="yes"/></li>
                </xsl:for-each>
                  </ul>
              </xsl:template>
    This properly lists subcategories but I am unable to create a link in the template match="Entity". I am trying to use
    Code:
    <a href="{aspdnsf:EntityLink(EntityID, SEName, Name, 0, '')}" title="{Name}">
    but it fails with an error of "A route named 'Airbrush' could not be found in the route collection. "

    Airbrush is one of my categories in the category list. I inserted all categories into the category table. This link works outside of the Entity template.

  6. #6
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    Try changing it to this:
    Code:
    <a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}">
    Last edited by webopius; 08-09-2011 at 10:43 AM. Reason: cant type

  7. #7
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    That was it! Thank you so much webopius!

  8. #8
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    On last question. Shouldn't the following pull the descendant's of the parent entity id?

    Code:
    /root/EntityHelpers/Category/descendant::Entity[EntityID=/root/EntityHelpers/Category/Entity[EntityID=/root/Runtime/CatID]/ParentEntityID]

  9. #9
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    I have my xml partially working. I am able to list out the entity name and sub categories below that. The problem I'm having is that when I'm in the lowest level, I want to show the sub categories of the parent entity ID. I have the following, but I cannot figure out the for-each portion . Any suggestions? Also, could this code be cleaned up any?

    Code:
    <xsl:template name="navigation">
                <xsl:choose>
                  <xsl:when test="count(/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/Runtime/CatID]) > 0">
                    <h3><xsl:value-of select="/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]/Name" disable-output-escaping="yes" /></h3>
                  </xsl:when>
                  <xsl:otherwise>
                    <h3><xsl:value-of select="/root/EntityHelpers/Category/descendant::Entity[EntityID=/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]/ParentEntityID]/Name" disable-output-escaping="yes" /></h3>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:apply-templates select="/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]"></xsl:apply-templates>
              </xsl:template>
    
              <xsl:template match="Entity">
                  <ul class="side-menu side-info">
                    <xsl:choose>
                      <xsl:when test="count(/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/Runtime/CatID]) > 0">
                        <xsl:for-each select="/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/Runtime/CatID]">
                        <li><a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                        </xsl:for-each>
                     </xsl:when>
                      <xsl:otherwise>                 
                        <xsl:for-each select="CANT FIGURE OUT WHAT TO DO HERE!!!!">
                        <li><a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                        </xsl:for-each>
                      </xsl:otherwise>
                   </xsl:choose>
                  </ul>
              </xsl:template>

  10. #10
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    I have this working finally! It took some time but well worth it. I call the navigation template in my template="/" and it will show the nav based on what category you are in. If you are in the lowest level category, it will show the parententity categorylisting.

    When in the lowest level, it does take extra time to build the nav it seems. Anyone have any suggestions for speeding it up or is it just my dev computer being slow?

    Code:
              <xsl:template name="navigation">
                <xsl:choose>
                  <xsl:when test="count(/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/Runtime/CatID]) > 0">
                    <h3><xsl:value-of select="/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]/Name" disable-output-escaping="yes" /></h3>
                  </xsl:when>
                  <xsl:otherwise>
                    <h3><xsl:value-of select="/root/EntityHelpers/Category/descendant::Entity[EntityID=/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]/ParentEntityID]/Name" disable-output-escaping="yes" /></h3>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:apply-templates select="/root/EntityHelpers/Category/descendant::Entity[EntityID=$CategoryID]"></xsl:apply-templates>
              </xsl:template>
    
              <xsl:template match="Entity">
                  <ul class="side-menu side-info">
                    <xsl:choose>
                      <xsl:when test="count(/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/Runtime/CatID]) > 0">
                        <xsl:for-each select="/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/Runtime/CatID]">
                        <li><a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                        </xsl:for-each>
                     </xsl:when>
                      <xsl:otherwise>
                        <xsl:for-each select="/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/EntityHelpers/Category/descendant::Entity[EntityID=/root/Runtime/CatID]/ParentEntityID]">
                          <xsl:choose>
                            <xsl:when test="EntityID = /root/Runtime/CatID">
                              <li><a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}" class="current"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                            </xsl:when>
                            <xsl:otherwise>
                              <li><a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                            </xsl:otherwise>
                          </xsl:choose>
                        </xsl:for-each>
                      </xsl:otherwise>
                   </xsl:choose>
                  </ul>
              </xsl:template>

  11. #11
    Kev is offline Junior Member
    Join Date
    Jun 2011
    Posts
    15

    Default

    Hey Chris - your site is snappy. Do you have any resources I could check out to optimize my windows server to speed up my sites? I saw your on what is now Earthlink..are you on a dedicated or are you doing colo? What has been your experience with them so far?

  12. #12
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    We are running aspdnsf 9013 on our current site. I haven't really done anything to the windows server or the application other than what is suggested here (http://manual.aspdotnetstorefront.co...checklist.aspx).

    I host our web server on our current data lines.

  13. #13
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    Any suggestions for making the following code a bit faster?

    Code:
    <xsl:otherwise>
                        <xsl:for-each select="/root/EntityHelpers/Category/descendant::Entity[ParentEntityID=/root/EntityHelpers/Category/descendant::Entity[EntityID=/root/Runtime/CatID]/ParentEntityID]">
                          <xsl:choose>
                            <xsl:when test="EntityID = /root/Runtime/CatID">
                              <li><a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}" class="current"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                            </xsl:when>
                            <xsl:otherwise>
                              <li><a href="{aspdnsf:EntityLink(EntityID, SEName, 'category', 0, '')}" title="{Name}"><xsl:value-of select="Name" disable-output-escaping="yes"/></a></li>
                            </xsl:otherwise>
                          </xsl:choose>
                        </xsl:for-each>
                      </xsl:otherwise>