We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10405
    • 288 Posts
    Hi, one thing I need to be able to do with Ditto is set up links to "previous months" of blog entries, for example June 2010, May 2010 etc.

    So far I have the following:

    [!Ditto? &parents=`10` &depth=`0` &extenders=`dateFilter` &dateFilterSource=`params` &year=`2010` &month=`7` &tpl=`ditto.previousmonths` !]

    The template is simply <p>[+month+][+year+]</p>.

    Rather than linking to a page with a listing of the old blogs though, it’s just listing "2010" over and over within the page column where I placed the call. I’ve read a bit about using the &get parameter but haven’t found anywhere that explains how it can be used easily.

    Ideally I’d like to have a new link appear when the current month becomes an "archive month" for example on August 1st it would be nice for "July 2010" to appear as a link in the Archives column, and when a user clicks on that link they get a listing of the blogs from that month.

    Not sure if this can be done easily though? I’ve tried creating a form in the column as follows:

    <form id="dateFilterForm" action="archives.html" method="get">
     <select name="year" size="1">
    <option value="""" selected="selected">- year-</option>
    <option value="2010">2010</option>
    </select>
    <select name="month" size="1">
    <option value="""" selected="selected">-- month --</option>
    <option value="1">January</option>
    <option value="2">February</option>
    <option value="3">March</option>
    <option value="4">April</option>
    <option value="5">May</option>
    <option value="6">June</option>
    <option value="7">July</option>
    <option value="8">August</option>
    <option value="9">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
     <input type="submit" name="Submit" value="Submit" />
    </select>
    </form>
    


    And then in the archives.html page, call a snippet which contains the following:

    <?php
    $year = $_GET['year'];
    $month = $_GET['month'];
    ?>
    


    I echo-tested this and it outputted the year and month.

    But I then tried this Ditto call below and it gave me "No documents found..."

    [!Ditto? &parents=`10` &extenders=`dateFilter` &dateSource=`pkDate` &dateFormat=`%d %b %Y` &params=`get` &year=`$year` &month=`$month` !]

    However I know I have two blogs for July this year (which is what i search on in the form).

    Anyone know why this is coming up empty?
      • 12379
      • 460 Posts
      Why don’t you just use Reflect with the Wordpress config for displaying blog archives?

      http://modxcms.com/forums/index.php/topic,14003.0.html
        Mostly harmless.
        • 20413
        • 2,877 Posts
        You would have to do
        year=`[[snippet]]`
        or
        year=`[+placeholder+]`
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 10405
          • 288 Posts
          Doesn’t seem to work... I edited the snippet so it just calls the year:

          <?php
          $year = $_GET['year'];
          //$month = $_GET['month'];
          echo $year;
          //echo $month;
          ?>
          


          And then called it within the Ditto call on the archives page:

          <p>Archives for [!archive_year_month!]</p>
          [!Ditto? &parents=`10` &extenders=`dateFilter` &dateSource=`pkDate` &dateFormat=`%d %b %Y` &params=`get` &year=`[!archive_year_month!]` !]
          


          Note that in the paragraph above the heading outputs correctly- it displays "Archives for 2010". But it still says there are no documents found. huh

            • 20413
            • 2,877 Posts
            Do [[ ... ]] cached snippet call when embed in a uncached snippet call [! ... !]
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 10405
              • 288 Posts
              Same result I’m afraid... sad

              Interestingly if I try setting up the Reflect method instead, although it appears to *almost* work, it outputs the date as 1 Jan 1970 for some reason!

              In the side column where I want to link to the archives, I’m using:

              [[Reflect?config=`wordpress` &targetID=`19` &dittoSnippetParameters=`startID:10`]]
              


              And in the main body column where I want the listings to appear:

              [!Ditto?startID=`10`  &extenders=`dateFilter`!]
              


              The main issue is that it’s not showing anything (e.g a link to the archives) in the column where I put the Reflect call, and in the main column, it seems to be outputting every resource regardless of date.
                • 10405
                • 288 Posts
                Tried Reflect again with the following call, but getting no documents:

                [!Ditto? &startID=`10` &tpl=`ditto.listingpreview` &filter=`id,12,2|id,13,2|id,14,2|id,15,2|id,16,2|id,18,2|id,19,2` &sortBy=`createdon` &showPublishedOnly=`1`  &extenders=`dateFilter`!]
                


                (Using the filter to stop container resources being displayed)

                However I just call as follows I get the containers showing-but not the blogs!

                [!Ditto? &startID=`10` &tpl=`ditto.listingpreview`  &extenders=`dateFilter`!]
                


                Clearly something’s working though, because if I change the start ID to 12 I get the tweo blogs which are inside the container with ID=12. And at least the dates work now. But the filtering doesn’;t seem to work when I call from the root container...
                  • 10405
                  • 288 Posts
                  Ok, using the filter with &depth=0 seems to work... only thing is I can’t yet see is if a new link will get automatically created for August, when the first August blog is created...