We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33114
    • 518 Posts
    I was trying to write my own filter and found out that if I add
    &extenders=`example`
    to my Ditto call (just anyone), for example to this one:
    [!Ditto? &tpl=`all_cat_item` &tplAlt=`all_cat_item_alt` &parents=`4818` &sortBy=`pagetitle` &sortDir=`ASC` &display=`80` &depth=`2` &hideFolders=`1` &hiddenFields=`videos` &seeThruUnpub=`0` &extenders=`example`!]
    - no documents are found. I suppose example filter must filter out docs with pagetitle ’foo’. I have no such docs... so I expect to receive normal output.

    What can be the problem? Mark?

    PS: I am using Ditto 2.1.0
      http://modx.ru - российская поддержка MODx
      http://newscup.ru - экспериментальный проект
      http://yentsun.com - персональный сайт
      • 18397
      • 3,250 Posts
      You are correct as this seems to be a bug introduced in the latest version. Please file a bug report for this in the Ditto bugtracker.
        • 18397
        • 3,250 Posts
        It looks like the values got swapped. The correct filter in the example should be:
        if (!function_exists("exampleFilter")) {
        	// wrap functions in !function_exists statements to ensure that they are not defined twice
        	
        	// ---------------------------------------------------
        	// Function: exampleFilter
        	// 
        	// Takes the resource array for an individual document
        	// and asks for the return of a 0 or 1 with 0 removing 
        	// the document and 1 leaving it in the result set. 
        	// In this case, if the lower case value of the pagetitle
        	// is foo, it is removed while all other documents are shown
        	// ---------------------------------------------------
        	function exampleFilter($resource) {
        		if (strtolower($resource['pagetitle']) == "foo") {
        			return 0;
        		} else {
        			return 1;
        		}
        	}
        }
        

        This has been fixed in the development version.
          • 33114
          • 518 Posts
          The bug is pinned down and the fix works well, thank you Mark!
            http://modx.ru - российская поддержка MODx
            http://newscup.ru - экспериментальный проект
            http://yentsun.com - персональный сайт