We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    I personally solved the problem in a snippet using the htmlspecialchars function

    $link = '<a href="'.$program['content'].'" target="_blank">'.htmlspecialchars($program['pagetitle']).'</a>';


    Probably the easiest solution is to create a PHx custom modifier called htmlspecialchars.

    Here’s the untested code:

    <?php
      $string=$output;
      return htmlspecialchars($string);
    ?>



    If you have PHx installed you should create a snippet called "phx: htmlspecialchars" with the above code

    In your template or chunk use [*pagetitle: htmlspecialchars*]

    Let me know if it works
      • 10189
      • 109 Posts
      Thanks for your suggestion, Cipa. I believe it will be difficult to get this to work in the wayfinder call I use to build the subnavigation on the site. Not really sure where to use the PHx modifier to be honest (I think I already use several of them).

      I’ll give it a try though. smiley
        • 10189
        • 109 Posts
        Didn’t seem to work. I used the PHx modifier on the longtitle tag and got the following from the log:

        4 [15:42:33] MODx TV/DV: longtitle
        5 [15:42:33]   |--- Input = 'Rehab & Prohab'
        6 [15:42:33]   |--- Modifier = ' htmlspecialchars'
        7 [15:42:33]   |--- Output = ''
        


        Nothing got processed, right?

        edit: My bad! Had a typo in the modifier! laugh
          • 5340
          • 1,624 Posts
          HI,

          There is a mistake in the snippet name

          You have a space before htmlspecialchars and after :

          remove that

          Use phx:htmlspecialchars

          In your wayfinder you need to use Template Chunks if you want to make this work. Documentation here

          Basically you need overwrite the default template chunks for wayfinder and use [+pagetitle:htmlspecialchars+]

            • 10189
            • 109 Posts
            I’m using custom template chunks for my Wayfinder call. However, I use [+wf.linktext+] and the modifier doesn’t seem to work with that one.
              • 10189
              • 109 Posts
              Ah, here’s the explanation about the wrapper placeholders:

              PHx support - its finally here, this needs major testing. The wrapper placholders cannot use Phx due to errors I was having with the nesting. All other tags should work.
                • 5340
                • 1,624 Posts
                I was using it with Ditto. I thought it should be the same for Wayfinder.
                I have another look
                  • 5340
                  • 1,624 Posts
                  I see 2 solutions

                  1. Modify wayfinder. Just htmlspecialchars the output
                  2. If it is a simple menu just make your own snippet using the modx api
                    • 10189
                    • 109 Posts
                    I’ll se what I can do about modifying Wayfinder. Thanks for your help! smiley
                      • 26931
                      • 2,314 Posts
                      That didn’t seem to do it for me. Maybe I’m doing it wrong?

                      that’s strange...the plugin works perfectly for me

                      maybe you’ve put the plugin code within php-tags? (you shouldn’t)