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

    I searched for this but I didn’t find anything... huh

    Is it possible to filter out (remove from listing) other snippets?
    For example, I have some documents with the fileDownload snippet and some other too. I don’t want them in my Ditto content, specially RSS.
    Can I removed them from Ditto’s output?

    Thank you!
    Boby
      ...my Photo Gallery on Flickr...
      • 18397
      • 3,250 Posts
      Yes, very easily. All you need to do is use this &filter=`id,baddocumentid,=` or if you want more than one ID excluded, separate each sequence in the filter parameter with a | character.
        • 3763
        • 155 Posts
        Hello Mark,
        I think I did not made myself clear enough or I’m just to dumb to understand the filter :’(

        Let me explain everything again...

        This is my Ditto call for the RSS feed:
        [!Ditto? &format=`rss` &startID=`9,18,26,38,39,40,47,51,65` &summarize=`10` &descendentDepth=`1` &multiLevel=`1` &showPublishedOnly=`1` &trunc=`0` &trunLen=`0` &commentsChunk=`FormBlogComments`!]

        Everything works fine with it.

        Some of the documents available in startID have basic text and a snippet call for FileDownload.
        Let’s say I have document 9 with this content:
        Blah Blah Blah Blah
        
        [!FileDownload?getFolder=`downloads` &getFile=`file1.zip` &downloadGroups=`Registered Users` &showExt=`zip` &downloadCount=`1` &chkDesc=`FileDownloadInfoFile` &tplList=`FileDownload` &useHlt=`1` &evenClass=`evenrow` &oddClass=`oddrow`!]
        
        Blah Blah Blah Blah

        And then I have document 65 with this content:
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
        
        [!FileDownload?getFolder=`downloads` &getFile=`file2.zip` &downloadGroups=`Registered Users` &showExt=`zip` &downloadCount=`1` &chkDesc=`FileDownloadInfoFile` &tplList=`FileDownload` &useHlt=`1` &evenClass=`evenrow` &oddClass=`oddrow`!]
        
        Nulla sagittis, mi nec elementum rhoncus, nisl enim egestas dui, eu sodales ligula metus et mi. Curabitur rhoncus eleifend odio. Phasellus justo ante, posuere at, mattis nec, posuere eu, ligula.


        I want now to have all the text of these documents (actually of all documents) available, but just remove this FileDownload snippet call from showing up. I don’t want to filter the complete document out, just a little piece of it.

        If it is possible, can you please show me an example?

        Thank you very much, and sorry for the many questions shocked grin

        Boby
          ...my Photo Gallery on Flickr...
          • 18397
          • 3,250 Posts
          That is not built into Ditto. However, if you use the same FileDownload snippet call each time, put it into a chunk and use the commentsChunk parameter to filter it out.
            • 3763
            • 155 Posts
            Ok, thank you smiley

            It’s not the same snippet call, but I will try to hack Ditto to remove the snippets from output.

            Boby
              ...my Photo Gallery on Flickr...
              • 18397
              • 3,250 Posts
              This function should do the trick.

                function stripSnippets($html) {
                  $t = $html;
                  $t = preg_replace('~\[\[(.*?)\]\]~',"",$t);	//snippet
                  $t = preg_replace('~\[\!(.*?)\!\]~',"",$t);	//snippet
                  return $t;
                }
              


              Place this in the Ditto class file and change this line:

              		$placeholders['[+summary+]'] = $summary;
              


              to this:

              		$placeholders['[+summary+]'] = $this->stripSnippets($summary);
              
                • 27
                • 117 Posts
                Quote from: Mark at Jul 17, 2006, 02:36 AM

                Yes, very easily. All you need to do is use this &filter=`id,baddocumentid,=` or if you want more than one ID excluded, separate each sequence in the filter parameter with a | character.

                Hi

                This isnt working for me, so I tried &filter=`id,baddocumentid,!=` instead and that didn’t work either - my perimeter appears in the snippet call as &filter=`id,666,!=` (the bad document I’m trying to hide errily has the document id 666) - I wonder what I’m doing wrong...

                0
                  • 18397
                  • 3,250 Posts
                  After more reasearch, it looks like the 0.9.2.1 parser strips out the = or != before sending it to the snippet. Try using ,1 or ,2 instead.