We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17412
    • 270 Posts
    Hi there, I've created a new output modifier "contains" ( from the Evo/Phx version: http://setpro.pl/software/ditto-stuff/obtaining-by-or )

    <?php
    return strpos($output, $options) === FALSE ? '0' : '1';
    


    I then place this in a getFeed rss template:

    [[+link:contains=`events`:is=`0`:then=`Post`:else=`Event`]]


    Alas, it works not. I've tested this outside of the template on a page looking at the pagetitle and again it doesn't work.

    Can anyone help out?

    This question has been answered by BobRay. See the first response.

      • 3749
      • 24,544 Posts
      Try $options[0] in the snippet.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 17412
        • 270 Posts
        Thanks Bob though no joy as yet.
        • discuss.answer
          • 3749
          • 24,544 Posts
          Sorry, I think you want this ($input, not $output):

          return strpos($input, $options[0]) === FALSE ? '0' : '1';



          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 17412
            • 270 Posts
            That seems to have done the trick, another cool filter in the toolbox, thanks Bob!
              • 38525
              • 26 Posts
              Definitely a cool filter! It's in my toolbox as well smiley

              However, I'm having some trouble now getting it to work with Formit checkbox and radio arrays. With checkboxes it looks like it's only taking the first letter of the array, with radio's I have no clue to what it does..

              Here's my code for the checkbox:
              <input type="checkbox" name="adv-paper-edition[]" value="[[+pagetitle]]" [[!+fi.adv-paper-edition:contains=`[[+pagetitle]]`:is=`1`:then=`checked`:else=``]] data-toggle="checkbox">
              


              It's a dynamic form by the way, where the checkboxes for the different paper editions are being listed by getResources. You can see the frontend of the form here: http://twedo.qaraqter.nl/informatief/adverteren/advertentie-plaatsen/

              I've tried using the If snippet with the inarray operator instead, but that won't fly either...

              Does anyone have any idea to why this doesn't work?
                • 4172
                • 5,888 Posts
                doesn't
                [[!+fi.adv-paper-edition:FormItIsChecked=`[[+pagetitle]]`]]

                work?
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 38525
                  • 26 Posts
                  Hi Bruno,

                  Thanks for your quick reply! Strangely enough it seems to work again now, but I replaced FormItIsChecked earlier with the other method due to issues with submitting..

                  Will test it more thoroughly later to see if it holds together..

                    • 40016
                    • 32 Posts
                    Based on the discussion in this topic I created the following:
                    <?php
                    //usage [[*pagetitle:contains=`kjk`:is=`1`:then=`yes`:else=`no`]]
                    if (strpos($input,$options) !== false) {
                    	return true;
                    }else{
                    	return false;
                    }


                    Works fine for me so I leave it here for anyone else wink