We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9133
    • 17 Posts
    I would like to sort monthly articles according to their date of publication (month, year).

    I have a TV called dateArticle in which I enter the actual date of the monthly article via Date Formatter

    Unfortunately the articles are sorted only by their ID. I would be grateful for a hint how to solve this problem.

    Thanks a lot in advance.



    My Ditto call is:
    [!Ditto_2? &startID=`1` &summarize=`5` &total=`all` &tpl=`DittoTemplate` &paginate=`1` &paginateAlwaysShowLinks=`1` &sortBy=`dateArticle DESC` &dateFormat=`%B %y` &extenders=`summary`&debug=`1` !] 
    
    <div id="ditto_pages"> [+previous+] [+pages+] [+next+] </div> 
    


    And the Ditto Template chunk is :

    <div class="ditto_documentInfo"><strong> [+dateArticle+]</strong> </div> 
    
    <div class="ditto_item" id="ditto_item_[+id+]">  <h3 class="ditto_pageTitle">[+pagetitle+]</h3>  
    
    <div class="ditto_introText">[+summary+] <a href="[~[+id+]~]">More</a></div></div>


      • 33992 ☆ A M B ☆
      • 455 Posts
      using &sortBy=`publishedon DESC` will sort them well. Why don’t you use it?
        God loves me. 【ツ】


        MODX.ir (Persian Support)

        Boplo.ir/modx/ (Persian)
        • 9133
        • 17 Posts
        Thank you very much for your suggestion, AHHP, but the problem is that I have to enter also old articles articles (from 2006) on this website, i.e. I need to have my "own" publication dates. This explains why I have the TV for "dateArticle".

        Any idea how I could solve this problem ?
          • 33992 ☆ A M B ☆
          • 455 Posts
          This parameter needs a database column with a comparable value such as integer.
          If you enter the dates like a number (e.g. 20090523 as 2009/05/23) or timestamp, MySQL see the value as a big number and can compare it but it can not compare something like this "2 2009" with "3 2009". MySQL see them as string!
            God loves me. 【ツ】


            MODX.ir (Persian Support)

            Boplo.ir/modx/ (Persian)
            • 9133
            • 17 Posts
            Thanks a lot ! Maybe this will help me, but since I am rather a beginner, I have to ask you more questions.

            Does it mean that I have to add a database column to the template variable ? And to add an integer (which one) to this new column ? Do I have to modify the Ditto call and the Dito template chunk ?
              • 33992 ☆ A M B ☆
              • 455 Posts
              The TV is db column you need.
              Ditto wants to compare your TV value but value is not comparable (i said before)
              So just enter a comparable value in this TV.
                God loves me. 【ツ】


                MODX.ir (Persian Support)

                Boplo.ir/modx/ (Persian)
                • 9133
                • 17 Posts
                Thank you !

                I guess I understood now the principle.

                I changed now in the Template Variable, the "Input type" to "Number" and enter the dates in the format 20061230 as you suggested. But it does not seem to work either.

                What to do ? Did I make perhaps a mistake in my coding ?
                  • 9133
                  • 17 Posts
                  Still no answer from anybody ?
                    • 33992 ☆ A M B ☆
                    • 455 Posts
                      God loves me. 【ツ】


                      MODX.ir (Persian Support)

                      Boplo.ir/modx/ (Persian)
                      • 3707
                      • 241 Posts
                      Thank you very much for your suggestion, AHHP, but the problem is that I have to enter also old articles articles (from 2006) on this website, i.e. I need to have my "own" publication dates. This explains why I have the TV for "dateArticle".
                      You could use the Doc Manager module to change the publication date of older articles back to 2006 or whenever. Then you could use publishedon to sort the articles.