We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10896
    • 76 Posts
    Hi I have a ditto call that gets titles and runs a secondary snippet on the titles before output. And I’ve found that the question mark symbol ( ? ) is stripped out and I’m wondering if there is a way to fix this.

    For example this is a title of a MODx document

    Coming to the conference?

    Here’s my sample Ditto call

    [!Ditto? &parents=`4` &tpl=`test_tpl` !]
    


    Here’s test_tpl at first -

    title - [+title+]
    


    And it outputs the title fine: ’Coming to the conference?’

    Then I created a snippet: testFunction

    <?php
    // testFunction
    return $str;
    ?>
    


    And I updated the tpl to be (noting the alternating snippet tags for embeded snippet in the tpl called by another snippet)

    title - [[testFunction? &str=`[+title+]` ]]
    


    and now it outputs this as the title:

    Coming to the conference

    Any thoughts?
      • 7231
      • 4,205 Posts
      Some chars do not work with snippet input parameters and I think that the ? is one of them. If you are using a snippet inside a Ditto tpl you might want to use PHx (built into the ditto tpl engine) to perform any action on a placeholder within a tpl.

      Look into the wiki under plugins for info on PHx (remember it is built into the ditto tpl system so you do not need to install PHx to use it in a tpl).
        [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&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 3749
        • 24,544 Posts
        It’s definitely a problem (solved, I think, in Revolution). I’ve gotten around it by encoding question marks and equals signs as QUESTION and EQUALS in the snippet call and decoding them just before output but that would be trickier in your situation. The only thing I can think of is to use another field (a TV or LongTitle, for example) that you don’t use for anything else and encode the offending characters there, then decode them in the last snippet before they’re returned as output.
          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
          • 10896
          • 76 Posts
          Thanks for the thoughts everyone.

          I think my issues were addressed by the PHx suggestion. The function I was including in the tpl chunk essentially was performing what the can be done with PHx like this

          [+title:htmlent+]

          So I think I’m good to go.

          Also, I’m glad to hear the ’bug’ is probably fixed in revolution. smiley