We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3493
    • 66 Posts
    Hi,

    I seem to be having problems using a placeholder in the filter clause.
    Here’s my filter call: &filter=`content,[+searchword+],7`

    What I’m trying to do here is to make Ditto my very own search engine, which crawls the document content for whatever [+searchword+] tells it to look for.

    Now, I’ve tried replacing "[+searchword+]" with "55 000", which worked like a charm. That listed up all the pages with 55 000 in their content.

    [+searchword+] is set by fetching a GET variable, and works everywhere else. I’ve even used it in the &noResults-paramenter just to check that everything’s fine with the searchword value.

    So is Ditto having trouble handling [+ +]’s (what’s their name again?) in a filter clause, or have I done something wrong? Is there any way to make this work by using custom filtering instad, maybe?


    Thanks!
      • 3493
      • 66 Posts
      I’ve been trying to figure this out, but from what I’ve understood this seems to be a bug. I’ll post it in the Bug Tracker now...
        • 18397
        • 3,250 Posts
        Depending on your MODx version, your placeholder [+searchword+] might not be replaced with its value before Ditto receives it. Thus, a workaround would be to create a pre-parsed filter in a new extender like so:

        $filters["parsed"][] = array('getFilter' => array("source"=>"content","value"=>$_GET['YOUR_FIELD_GOES_HERE'],"mode"=>"7"));
        	// Variable: $filters["parsed"][]
        	// Add the pre-parsed filter to the parsed filters list where YOUR_FIELD_GOES_HERE is the name of your get field.