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


    Announcing Ditto: the nimbler, faster, better-named and even more flexible offspring of NewsListing.

    The fact is, Newslisting is useful for much more than summarizing and building archives of news articles. Coupled with the fact that a cornerstone MODx philosophy focuses on flexibility, and "News" seemed to syntactically restrictive. And boring.

    Blogs... PodCasts... Press Release archives... File Download repositories... FAQs... Executive Bio listings...

    Ditto now takes advantage of an external class, language files to work with multi-language installs, and uses templates extensively for the ultimate in output formatting flexibility and control. And while it has more than 40 configurable parameters in it’s current implementation, you only need [[Ditto]] for great results (although telling it explicitly where to start probably wouldn’t hurt wink ).

    Amongst the many cool things under Ditto’s able and refined domain:

    • &mode parameter can disable sanity checks on variables and increase speed for production sites.
    • JSON format for AJAX applications
    • Access individual posts in templates via [+item[ # ]+] placeholders (replacing ’ # ’ with actual integers).
    • Stop guessing with non-abbreviated parameter names in CamelCase convention.
    • Updated documentation and full parameter and placeholder lists.
    • xHTML Strict month-based archive output which uses templates for formatting.
    • Extensive sorting and filtering based on TVs
    • And the obligatory, "much, much more..."

    Download:

      • 19777
      • 35 Posts
      Great update!

      However, I still have no idea how to use &filter. I really want to be able to add tags to my documents and categorise them. But I still get the message ’No entries found.’. Sorry to be a pain about this, but it is the only thing stopping me putting my site up at the moment.

      I have a series of documents with a TV called ’Category’. I’ve put some arbitrary words in the TV to act as my tag - the words ’red’ and ’blue’.

      I have a document, the Blue Archive page which acts as a listing of all documents with the word ’blue’ in their Category TV, with the following in my Document Content:

      [!Ditto? &startID=`41,42` &summarize=`4` &sortDir=`ASC` &tpl=`HomeSmall` &truncText=`More` &paginate=`1` &increment=`4` &filter=`tvCategory,blue,1` !] [+previous+][+pages+]{+next+]


      Obviously, I’m not using the call correctly, but what am I doing? I’ve tried heaps of combinations with little success. I always get ’No entries found’ when i know they exist. Please help!

      Again, thanks for a wonderful snippet Mark!

      mark j
        • 18397
        • 3,250 Posts
        You are using the call correctly, but as I stated in the NewsListing thread, I am still working on figuring out how to handle tagging. The call you are using is saying that if the tv Category is equal to blue (not containing blue) then only show it.
          • 24292
          • 28 Posts
          Brilliant. Arrived just as I needed it.

          Two little problems. First - is dateFormat the same as in NewsListing?
          I have
          [[Ditto? &startID=`7,30,28` &filter=`tvfrontpage,Yes,=` &hiddenTVs=`frontpage,section` &tpl=`NewsItem`&summarize=`5` &displayArchive=`0` &sortBy=`editedon` &dateFormat=`%A %d %B %Y %H:%M`]] 

          but it seems to ignore whatever I set for dateFormat.

          Second - ’section’ is a TV with default value @INHERIT default. I have different section of the tree and style them differently in css, which works fine. However when I use the TV in Ditto template as [+tvsection+] it always has vaue ’default’ unless I set it explicitly for that document. Should it be able to handle inherited TV values?
            • 18397
            • 3,250 Posts
            Ok, faulty search and replace.

            Replace this:

            $dateFormat = isset($dateFormatformat)? $dateFormatformat : $_lang['date_format'];
                // format for the summary post date format
            


            With this:

            $dateFormat = isset($dateFormat)? $dateFormat : $_lang['date_format'];
                // format for the summary post date format
            
              • 32484
              • 5 Posts
              Tried, nice updates for giving more flexible and support. However, it seems some stuffs aren’t in the right shape like search, [!snippet!] function, data query, multiple startid, etc. It would be great if you can sort out all of these and make shortening [+title+] possible. I mod newslisting to support shortening title feature like summary for my sidebar. I don’t know why I can’t do the same to Ditto. It would be good if you add trunc... features from summary to title also.
                • 18397
                • 3,250 Posts
                Windows X, I don’t know what you are talking about. Ditto works fine with [!Ditto!] and [[Ditto]] and multiple startID’s work fine as well. Additionally, you can you any field you wish such as [+menutitle+] for shortened titles.
                  • 22221
                  • 283 Posts
                  I think there is the same problem with the "descendentDepth" parameter :

                  Find the code :
                  $descendentDepth = (isset($levelLimit))? $levelLimit : 0;
                  	// number of levels deep to go, 0 indicates infinite

                  And replace by :
                  $descendentDepth = (isset($descendentDepth))? $descendentDepth : 0;
                  	// number of levels deep to go, 0 indicates infinite


                  Mark do you confirm my patch ?

                  Edited :
                  I found another stange behaviour. When I delete a document but don’t empty the trash, document are still displayed with Ditto huh
                    • 19777
                    • 35 Posts
                    Hi Mark,

                    I’ve been playing with trying to get the tag/categories to work as I’d described earlier. I’ve found that if you replace (in the ditto.class.inc.php):

                    case 1 :
                    if (!isset ($r[$filterKey]) || $r[$filterKey]!=$filterName) $unset=1;


                    WITH

                    case 1 :
                    if (!isset ($r[$filterKey]) || ereg($filterName,$r[$filterKey]) != '1') $unset=1;


                    You can filter by a value in a TV, using a call such as:

                    [!Ditto? &startID=`41,42` &summarize=`4`&sortDir=`ASC` &tpl=`HomeSmall` &dateFormat=`%d %B %y` &truncText=`More` &paginate=`1` &increment=`4` &filter=`tvCategory,Travel,1` !]


                    Which shows all documents that match the word ’Travel’ in the Category TV. Currently I have 3 documents with ’Photography, Travel’ in my Category TV - and it works.

                    However, I’ve noticed that unless I have a chunk template (in this case ’Homesmall’) with the TV declared in a placeholder (in this case [+tvCategory+]) that TV is not being filtered and is not in the $resource array. I’ve tried to put &hiddenTVs=`Category` in the call but that did nothing.

                    To see what was going on, I used the following in the ditto.class.inc.php:

                    case 1 :
                    print_r($resource[$k]);
                    



                    I’m not yet sure how to get the $resource array to include my TV (category in my case) without declaring it in my Chunk with [+tvCategory+]. Like I said, I’ve tried &hiddenTVs=`Category` to no avail.

                    Cheers

                    mark j
                      • 33453
                      • 141 Posts
                      I am experiencing a slight problem.

                      I have a snippet
                      <h2>features</h2>
                      <div class="box">
                        [!Ditto10? &startID=`2` &summarize=`3` &total=`3` &truncSplit=`0` &tpl=`NewsHeadlines`!]
                      <a class="small" href="features.html">More Features</a>
                      </div>
                      <h2>reviews</h2>
                      <div class="box">
                        [!Ditto10? &startID=`3` &summarize=`3` &total=`3` &truncSplit=`0` &tpl=`NewsHeadlines`!]
                      <a class="small" href="reviews.html">More Reviews</a>
                      </div>
                      <h2>news</h2>
                      <div class="box">
                        [!Ditto10? &startID=`4` &summarize=`3` &total=`3` &truncSplit=`0`  &tpl=`NewsHeadlines`!]
                      <a class="small" href="news.html">More News</a>
                      </div>


                      The template is
                      <div class="newsheadline">
                        <p>
                          <a href="[~[+id+]~]"><img src="[+tvStoryImage+]" alt="link to story"/><strong>[+title+]:</strong> [+summary+]</a>
                      </p>
                      </div>
                      


                      This should produce 3 boxes, each containing the first 3 summaries from their respective categories. However, only the first displays as it should, the others show no results. I have varied the order in which they are displayed and whichever comes first is OK, the subsequent ones are not. I have also set them to all display the same startid - in this case the display is as expected.

                      This is the HTML generated
                      <div id="block_1">
                      
                        <div class="newsheadlines">
                        
                          <h2>features</h2>
                          <div class="box">
                      
                            <div class="newsheadline">
                              <p>
                                <a href="features/one-life-stand.html">
                                  Image and text .....
                                </a>
                              </p>
                            </div>  <!-- newsheadline -->
                      
                            <div class="newsheadline">
                              <p>
                                <a href="features/one-life-stand2.html">
                                  Image and text .....
                                </a>
                              </p>
                            </div>  <!-- newsheadline -->
                      
                            <div class="newsheadline">
                              <p>
                                <a href="features.html">
                                    Image and text .....
                                </a>
                              </p>
                            </div>  <!-- newsheadline -->
                            <a class="small" href="/one-life-stand3.html.html">More Features</a>
                          </div>  <!-- box -->
                      
                          <h2>reviews</h2>
                          <div class="box">
                            <div class="newsheadline">
                              <p>
                                <a href="[~~]"><img src="" alt="link to story"/><strong>:</strong> </a>
                              </p>
                            </div>  <!-- newsheadline -->
                            <a class="small" href="reviews.html">More Reviews</a>
                          </div>  <!-- box -->
                      
                          <h2>news</h2>
                          <div class="box">
                            <div class="newsheadline">
                              <p>
                                <a href="[~~]"><img src="" alt="link to story"/><strong>:</strong> </a>
                              </p>
                            </div>  <!-- newsheadline -->
                            <a class="small" href="news.html">More News</a>
                          </div>  <!-- box -->
                        </div>  <!-- newsheadlines -->
                      </div> <!-- block 1 -->


                      I have FURLs turned on to use entire path and allow duplicate entries.

                      Any ideas what might be wrong?

                      Thanks.

                      This discussion is closed to further replies. Keep calm and carry on.