We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29181
    • 480 Posts
    My client has quite a complicated Document tree where some branches are longer than others. At the moment whenever they want to create a new branch they have to set a TV to the DocID of the top level document (Although it has a parent or 2 meaning I can’t use UltimateParent). After a few sleepless nights I think a possible solution would be to use @eval to say something like:

    if the template that this documents parent is using is called Mainmenu set this TV to this documents ID otherwise inherit from it’s parent.

    Can anybody tell me if it is possible to do this? The testserver is at www.olson.bz for anyone who wants to see the menu setup...although currently only "who we are" and its children have been populated.

    Thanks for any help!!!

    Flash-Genie
      Adrian Lawley: www.adrianlawley.com
      • 7455
      • 2,204 Posts
      You could use SectionRoots for this I think with this snippet you can set an array of parents to search for below the active documents I used it alot for mutilangual sites where my ultimate parents where the languages and the folders in that folder needed to be my ultimate parents, the id’s to make sub menu’s from.

      if the document is not below the items you like in the menu you could use MenuDealer.


      Greets Dimmy
        follow me on twitter: @dimmy01
        • 29181
        • 480 Posts
        Thanks Dimmy, I think SectionRoots may be just what I was looking for. I’ll give it a shot.

        [EDIT]It was, thanks again! A lot tidier than using TV’s that someone someday will accidentally change making it all blow up wink[/EDIT]
          Adrian Lawley: www.adrianlawley.com
          • 29181
          • 480 Posts
          Going back to the @eval question, I have a few problems if I try to use @inherit somewhere else. If it’s not defined then it causes all sorts of "What happened there"s so could I say

          if defined use @inherit otherwise use this documents docId, that would make it failsafe.

          Thanks for any advice.
          Taff
            Adrian Lawley: www.adrianlawley.com
            • 7455
            • 2,204 Posts
            you could set a standard value in the tv when you create a tv

              follow me on twitter: @dimmy01
              • 29181
              • 480 Posts
              Thanks again for you help.

              How would I set a standard value? Do you mean the Default value? If so can I use @inherit and the default value in the same field, because that is essentially what I am trying to achieve.

              Cheers,
              Taff
                Adrian Lawley: www.adrianlawley.com
                • 7455
                • 2,204 Posts
                I use this alot I set @INHERIT as default
                  follow me on twitter: @dimmy01
                  • 29181
                  • 480 Posts
                  Hey Dimmy,

                  I’ll try and explain a little more, I think we are crossing wires

                  I am currently using @inherit and it works fine, but I need to define the top level of the branch so that I can link back to it. This is OK for as long as I’m doing it...I set the TV in the top level of the branch to it’s ID and leave all the others at their default value (@inherit) That way no matter where I am in the branch the TV will always point to the top of the branch. (Pretty much like using SectionRoots where I define it up front).

                  The question is what happens when my client needs to create a new branch...If they don’t set the TV of the top document manually....none of the @inherits will work, because it hasn’t been defined anywhere at all, thus breaking all my links. The same problem is with SectionRoots, they need to add the docId to the array when calling the snippet.

                  For this reason I need a way to automatically define the TV if the parent docs TV isn’t set yet (Then I know i’m at the top of the branch) so I need something along the lines of

                  Pseudo-code:

                  @EVAL 
                  if isset($modx->[*parent*][myTemplateVariable]){
                  @inherit
                  }else{
                  myTemplateVariable=$modx->docId
                  };


                  Thanks again for all your help so far!

                  Taff
                    Adrian Lawley: www.adrianlawley.com
                    • 29181
                    • 480 Posts
                    Bumpity bump...because I’m not getting anywhere wink

                    Even a "It can’t be done ever ever ever" would help.......I suppose.

                    Thanks for any advice!
                    Taff
                      Adrian Lawley: www.adrianlawley.com
                      • 7455
                      • 2,204 Posts
                      Sorry for not answering I am in the middle of a big project, wil answer when I have som time to figre this out.
                      maybe somone else knows this and could help you.

                      Dimmy
                        follow me on twitter: @dimmy01