We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53335
    • 2 Posts
    Simpliest example of problem (on clean modx 2.5.5):

    [[*published:is=`1`:then=`
        [[*alias]]
        [[*pagetitle:is=`Home`:then=`
           [[*alias]]
        `]]
    `]]
    


    Outputs: index `]]

    If there are two identical tags ([[*alias]] in example) in nested conditional tags parser produce weird output.
    It can be solved by moving part of code to another Chunk to avoid identical tags in one code but I think there are some problems in parser.

    Tested on php 5.3 and 7

      • 3749
      • 24,544 Posts
      The parser sometimes has trouble with modifiers that have a 'then' clause with no 'else'. That could be the problem, or you could be right that it's the nesting. Output modifiers aren't really intended to solve problems that involve complex decision-making.

      If I'm reading your code correctly and it worked as it should, the alias would be displayed twice if you're on the home page and it's published. Is that really what you want?

      Since the Home page would always be published and its pagetitle would be Home (right?) the inner part seems unnecessary, but maybe I'm missing something.

      Your code would probably work, and produce the same result if you did this:

      [[*published:is=`1`:then=`
          [[*alias]]']]
      
      [[*pagetitle:is=`Home`:then=`[[*alias]]`]]
      


      I was going to offer a simple snippet that would do the job much faster than nested conditional output modifiers, but I can't tell for sure what you're trying to accomplish.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 53335
        • 2 Posts
        Thanks for your answer.

        Example code is just demonstration.
        We faced this problem in more complex situation.
        I simplified it to find the cause.
        In fact there is no matter what is in conditions, problem is in duplicate variables with nesting. If I change one [[*alias]] to something other it will output 'index something' as expected.

        I understand how we should avoid it, thanks, just wanted to report it.
          • 52064
          • 120 Posts
            FerX - Developer at Eracom s.r.l.
            • 3749
            • 24,544 Posts
            Good detective work on the duplicate placeholder. Thanks for reporting it. smiley

            I would have thought the parser would replace all simple resource content tags on the first pass.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting