We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    I have this structure on my site
    products(10)
     >>>Men(12)
       >>Sub category(13)
       >>>Sample item (27)
       >>Sub category(14)
     >>>Women
       >>Sub category(16)
       >>Sub category(17)
    


    and I want display a chunk depending on which category user is on.
    I tried this hoping it’ll return my subcategory doc id 13 but I get the no go smiley
    [+phx:if=`[!UltimateParent &top=`12`!]`:is=`13`:then=`Yes Go!`:else=`No Go!`+]


    anyone see whats wrong?

    btw, is there a simpler way to do that like [+phx:if=`[*id*]parent`:is=`13`:then:=`blah...`]?
      • 4172
      • 5,888 Posts
      you can try this:
      [*parent:is=`13`:then=`Yes Go!`:else=`No Go!`*]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 7231
        • 4,205 Posts
        I think that your UP call would work if it was like this:
        [!UltimateParent &topLevel=`2`!]


        This will return the ID of the document 2 levels deep from the root, but you need to be below it for it to work, otherwise UP fails.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 27330
          • 884 Posts
          Quote from: Bruno17 at Oct 26, 2008, 05:14 AM

          you can try this:
          [*parent:is=`13`:then=`Yes Go!`:else=`No Go!`*]

          Thanks that work perfect. this is awesome, just what I needed. great modx laugh

          Quote from: dev_cw at Oct 26, 2008, 12:34 PM

          I think that your UP call would work if it was like this:
          [!UltimateParent &topLevel=`2`!]

          This will return the ID of the document 2 levels deep from the root, but you need to be below it for it to work, otherwise UP fails.

          I couldn’t get it to work for some reason. Anyhow the direct parent:is way seems more suitable for what I need it.

          Thank you both, really appreciate it.

          phx make life so much easier for the coder wannabe smiley
            • 27330
            • 884 Posts
            how about elseif and OR is there a way to do it with phx?
            ie something like this:

            [+phx:if=`[*product-sizes-shirts-xs*]`:ne=``:then=`Yes Go!`:
            elseif:`[*product-sizes-shirts-sm*]`:ne=``:then=`Yes Go!`:
            elseif:`[*product-sizes-shirts-med*]`:ne=``:then=`Yes Go!`:
            elseif:`[*product-sizes-shirts-lg*]`:ne=``:then=`Yes Go!`:
            else=`No Go!`+]
            
              • 7455
              • 2,204 Posts
              Quote from: sinbad at Oct 31, 2008, 05:54 AM

              how about elseif and OR is there a way to do it with phx?
              ie something like this:

              [+phx:if=`[*product-sizes-shirts-xs*]`:ne=``:then=`Yes Go!`:
              elseif:`[*product-sizes-shirts-sm*]`:ne=``:then=`Yes Go!`:
              elseif:`[*product-sizes-shirts-med*]`:ne=``:then=`Yes Go!`:
              elseif:`[*product-sizes-shirts-lg*]`:ne=``:then=`Yes Go!`:
              else=`No Go!`+]
              


              I am also wondering if this is working in phx
                follow me on twitter: @dimmy01
                • 4172
                • 5,888 Posts
                Perhaps in this case you can try it with:
                [+phx:if=`[*product-sizes-shirts-xs*][*product-sizes-shirts-sm*][*product-sizes-shirts-med*][*product-sizes-shirts-lg*]`:is=``:then=`No Go!`:
                else=`Yes Go!`+]
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 3707
                  • 241 Posts
                  There’s no elseif in PHx but you can nest more PHx tags inside the else. It does make for quite long statements though.
                  [+phx:if=`[*product-sizes-shirts-xs*]`:ne=``:then=`Yes Go!`:
                  else`[+phx:if=`[*product-sizes-shirts-sm*]`:ne=``:then=`Yes Go!`:
                  else=`[+phx:if=`[*product-sizes-shirts-med*]`:ne=``:then=`Yes Go!`:else=`No Go!`+]`+]`+]
                    • 7455
                    • 2,204 Posts
                    in my case I made a small snippet for it:

                    This snippet wil use ultimateparent (for wayfinder in my case) if the page is not below $topId
                    if the document viewed is below the $topId then it will look if the parent of the document is not the same as $topId, if that is the case parent is used for wayfinder (in this case) (menu level 2 is made)
                    if the parent id the same as topId then the current id is used as startId for wayfinder (in this case)

                    <?php
                    $up = $modx->runSnippet('UltimateParent');
                    $parent = $modx->documentObject['parent'];
                    $id = $modx->documentObject['id'];
                    if(isset($topId)){$tid = $topId;}else{$tid = $up;}
                    
                    if( $up == $tid AND $parent != $tid){return $parent;}
                    if( $up == $tid AND $parent == $tid){return $id;}
                    if( $up != $tid){return $up;}
                    ?>
                    
                      follow me on twitter: @dimmy01