We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18907
    • 5 Posts
    I have a list of press items added to my Modx site. They are all listed in the order of the date they were published. However, I also have a press archive where you can see all the press items from a certain year. I’m not sure how to use Ditto to firstly generate a link for each year there are press items for (i.e. I have press items from 2004 - 2007, I want a to dynamically generate the links for ’Press from 2004’ and ’Press from 2005’ etc...). Then, when someone clicks the link, I want to filter the ditto pages so that they only see press items from that year.

    I’m really not sure how to go about doing this, so any pointers in the right direction would be much appreciated.
      • 6726
      • 7,075 Posts
      Good news is, you don’t need to do anything except learn how to use the Reflect snippet, Ditto’s little brother which handles archives exactly how you want them. Reflect is bundled with MODx btw smiley

      Doc : http://ditto.modxcms.com/files/snippet-reflect-php.html

        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 18907
        • 5 Posts
        Great, thanks, I really appreciate the help!
          • 18907
          • 5 Posts
          Ok, I have gone through reflect and it’s really simple to use. I have it working exactly how I want it with one slight exception. When I generate the archive menu, it generates the months as well as the years. I just want the years to show. How do I turn off months? Here is how I’m currently calling Reflect:

          [!Reflect? &parents=`4022` &dateFormat=`%y` &tplContainer=`press archive years` &tpl=`press archive` &showItems=`0` &dateSource=`pub_date` &tplMonth=`` &tplYear=`press archive` !]


          I set the month template to blank, but it still generates the <li> etc. Here’s the full source being generated by Reflect:

          <ul class="reflect_archive">
              <li class="reflect_year"><a href="/press.html?archive_year=2007" class="linkArrow">2007</a>
                  <ul>
                      <li class="reflect_month"> </li>
                  </ul>
              </li>
              <li class="reflect_year"><a href="/press.html?archive_year=2006" class="linkArrow">2006</a>
                  <ul>
                      <li class="reflect_month"> </li>
                  </ul>
                  <ul>
                      <li class="reflect_month"> </li>
                  </ul>
                  <ul>
                      <li class="reflect_month"> </li>
                  </ul>
              </li>
          </ul>