Copied to clipboard

Flag this post as spam?

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


  • sravani 50 posts 70 karma points
    May 24, 2011 @ 13:30
    sravani
    0

    how to select every time first child of the parent node in 2nd level navigation

    Hi All,

    my code is...

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library"
      exclude-result-prefixes="msxml umbraco.library">
       
    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:template match="/">

      <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
     
    <!-- The fun starts here -->
       
    <xsl:if test="count($items) &gt; 0">
    <ul>

    <xsl:for-each select="$items">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
        </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    It working perfect to me but I need every time I have to select the firstchild node with related content How can I achieve that??

    Pls any ideas share with me......

    Thanks in adavance...

  • Pasang Tamang 258 posts 458 karma points
    May 24, 2011 @ 16:08
    Pasang Tamang
    0

    Hi

    Give a try using position. if the position is 1 then select that one only. like

    <xsl:if test="position()=1">sometext</xsl:if>

    Thanks

    Pnima

  • sravani 50 posts 70 karma points
    May 27, 2011 @ 06:57
    sravani
    0

     

    Can pls explain me in detailed ?? 

    Thanks,

    sravani

     

     

     

  • sravani 50 posts 70 karma points
    May 27, 2011 @ 07:00
    sravani
    0

    My menu is like 

    Community

       .customer

       .support

    When I select the Community by default  every time my  first child node (customer) is in active.

     

    Thanks

    sravani

     

     

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 27, 2011 @ 10:40
    Dennis Aaen
    0

    Hi sravani,

    Perhaps you could try something like this.

    <xsl:template match="/">

    <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
     
    <!-- The fun starts here -->
    <xsl:if test="count($items) &gt; 0">
       
    <ul>
           
    <xsl:for-each select="$items">
               
    <xsl:if test="position()=1">
                   
    <li>
                       
    <xsl:attribute name="class">
                            selected
                       
    </xsl:attribute>
                       
    <a href="{umbraco.library:NiceUrl(@id)}">
                       
    <xsl:value-of select="@nodeName"/>
                       
    </a>
                   
    </li>
               
    </xsl:if>    
           
    </xsl:for-each>
       
    </ul>
    </xsl:if>
    </xsl:template>

    If this works as I hope, your first li tag in the 2nd navigation should get the class="selected", and now you can add for example font-weight: bold; in your css to that selector, so the first list element in the 2nd navagation will get bold.

    I have not tested this myself, but I hope it can help you, if I understood your question correctly.

    /Dennis


  • sravani 50 posts 70 karma points
    May 27, 2011 @ 12:35
    sravani
    0

    Thanks Dennis,

    It works perfectly but it is displying only one child node that to first node remaing nodes are not  displayed. I need to select first node every time remaining nodes need to be displayed along with related content. 

    Regards,

    Sravani

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 27, 2011 @ 12:50
    Dennis Aaen
    0

    Hi again,

    Hello again,
    I think I know what the problem is. The problem as I see it, because I came to put the if condition outside the li tag so you will only get the first
     
    Try this instead

    <xsl:template match="/">

    <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
     
    <!-- The fun starts here -->
    <xsl:if test="count($items) &gt; 0">
        <ul>
            <xsl:for-each select="$items">
                    <li>
                <xsl:if test="position()=1">
                            <xsl:attribute name="class">
                                selected
                            </xsl:attribute>
                </xsl:if>
                            <a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="@nodeName"/>
                            </a>
                    </li>   
            </xsl:for-each>
        </ul>
    </xsl:if>
    </xsl:template>

     Hope this will work as it should.

    /Dennis


  • sravani 50 posts 70 karma points
    May 27, 2011 @ 13:00
    sravani
    0

    Thanks Again,

    It is not working ...... 

    Regards,

    sravani

     

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 27, 2011 @ 13:28
    Dennis Aaen
    0

    Hi,

    I came to post a little early before so I changed the code in relation to what you got by email. Do not know if it's the version you have tested.

    I'll try to help the best I can:)

    /Dennis

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 27, 2011 @ 21:27
    Dennis Aaen
    1

    Hi Sravani,

    I've now had the opportunity to test the xslt which I wrote to you earlier to day.

    I've now had the opportunity to test the xslt which I wrote to you earlier in the day.
    And with this code below I get
    displyed all childs of the currentpage, and the first li gets the class "selected".

    <xsl:template match="/">

    <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
     
    <!-- The fun starts here -->
    <xsl:if test="count($items) &gt; 0">
        <ul>
          <xsl:for-each select="$items">
            <li>
              <xsl:if test="position()=1">
                <xsl:attribute name="class">
                  selected
                </xsl:attribute>
              </xsl:if>
                <a href="{umbraco.library:NiceUrl(@id)}">
                 <xsl:value-of select="@nodeName"/>
                </a>
            </li>    
         </xsl:for-each>
        </ul>
    </xsl:if>
    </xsl:template>

    So hope you will get it work with this code.

    /Dennis

  • sravani 50 posts 70 karma points
    May 30, 2011 @ 11:32
    sravani
    0

    Thanks for your reply,

    I guess my explaination is not clear 

    I have main menu  Community ,Company......etc

    and 2nd level navigation for Community ------ 1.customer 2. Support & 

                                                    Comany---------- 1. About us,2.Management 3.contact us

    when I am select the main menu tab means Community I need !st child ie. customer is selected and display content in customer page same for comapny -- I need About us page 

    Thanks a lot for u r replies......  :)

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 30, 2011 @ 15:20
    Dennis Aaen
    0

    Okay. Unfortunately I misunderstood your question. I am very sorry.

    Hope you find a solution to your problem.

    /Dennis

  • Sean Holmesby 61 posts 82 karma points
    May 31, 2011 @ 03:08
    Sean Holmesby
    0

    So, if I'm reading this correctly, you don't want a page for Community.... but that's more the title for all of the nodes below in (Customer, Support etc...)...

    If that's the case, what you can do is set up an umbraco redirect, so that when they click on Commuity, instead of going to the Community page, they get redirected to the document that you've selected it to go to.

    To do this, you should add a content picker to each of your top level pages, and give it the property alias 'umbracoRedirect'. Then for each of your pages, select the first child in that redirect field. Umbraco should automatically redirect to that sub page.

    http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracoredirect

    I know this isn't ideal, as it won't automatically pick up your first child item, but if you want to keep that site structure, and still have the functionality you're requesting, then I think it's the best way.

     - Sean

  • sravani 50 posts 70 karma points
    Jun 02, 2011 @ 14:43
    sravani
    0

    Thanks for the Reply ,

    I tried the content picker and link to the child page content but it is not redircte to that page.

    It show me the same result.

     

    Regards,

    Sravani

  • Sean Holmesby 61 posts 82 karma points
    Jun 03, 2011 @ 01:20
    Sean Holmesby
    0

    Hmmm, weird.

    I haven't used this myself, so this is kind of the blind leading the blind. Reading the documentation, umbracoRedirect is supposed to just be a temporary thing, not a permanent thing. Instead, you should try using this package:-

    http://our.umbraco.org/projects/backoffice-extensions/permanent-redirect

    Follow the instructions, and see if it works. Not sure why the other one didn't work though.

  • sravani 50 posts 70 karma points
    Jun 03, 2011 @ 07:21
    sravani
    0

    Thanks All,

    Problem is solved with  umbracoInternalRedirectId & content picker ..... :)

    Regards,

    Sravani

Please Sign in or register to post replies

Write your reply to:

Draft