We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17883
    • 1,039 Posts
    Can´t believe it...

    Problem: I wanted to create a TV in the date format, which is no problem. After creating I realized that there is this nice calender-popup for inserting the date. Easy for the customer, good for me. Now this TV displayed the date in the format "22-03-2006 00:41", but I just need the date, not the time. Okay then, I know MODx is flexible, so why not format the TV via snippet to eliminate the time and display only the date?! Yes, no problem, just created a snippet which reduced the given string (TV) to the date. Works perfect. Now I had the dilemma that I need this date displayed by the newslisting snippet, and this of course is not possible because Newslisting doesn´t execute the snippet. Well, it´s late over here and I thought "well then, let´s take a look in the core (the first time!) where the date is formatted and change it to my claim. Then I read something in this core file about a "date widget" and I thought "well, never took a look at this, don´t even know for what they are good for (except something like marquee which I don´t need)". And there it was: widget: date -> widget properties: date formatter... AWESOME. So one more time no change of core files needed, just done with that.

    Had to write this down and say once more THANK YOU for this System smiley

    Marc
      • 10487 MODX Staff
      • 1,535 Posts
      Great example of just how flexible and versatile MODx is! laugh Thanks for posting!
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 25663 MODX Staff
        • 12,272 Posts
        But did it wash the dishes in your sink for you? tongue
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 17883
          • 1,039 Posts
          Quote from: rthrash at Mar 21, 2006, 05:55 PM

          But did it wash the dishes in your sink for you? tongue

          Well, not yet. But perhaps I oversaw some more features laugh
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Well, we do need some reason to get up from in front of the computer sometimes wink
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 12462
              • 3 Posts
              Just installed a sink by my desk to avoid just that! tongue

              Im trying out modx for a few days now, and the progress i made is just great! I was looking for a tool like this for a long time, its solid and fexible for our needs, just love it.

              However, with the date formatter im trying to use international names, for the months, and cant understand yet how i would be able to do that. Im looking for a solution for the last days in the forum and googling about it, but no easy way out. Can you guys share your knowledge on this? laugh

              Thanks.
                • 12462
                • 3 Posts
                Man, was this easy. Just did some reading and got a solution really quick:

                For the portuguese months (or in any other languages for that mather), just did this:

                New snipet called [[months]]

                with this code inside:

                <?php
                //complete with the day of the week, just include another param to the snippet call bellow
                //echo returnDate(date("N"), "day") . ", " . date("j") . " de " . returnDate(date("n"), "month") . " de " . date("Y");
                
                //just the month
                echo returnDate(date("$parameter"), "month");
                
                    function returnDate($num, $tipe){
                        $str;
                        switch($tipe){
                            case "month":
                                $month_name = array("", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");
                                $str = $month_name[floor($num)];
                                break;
                            case "day":
                                $day_name = array("", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado", "Domingo");
                                $str = $day_name[floor($num)];
                                break;
                        }       
                        return $str;
                    }
                ?>


                Then in the Date TV just added this code to the Date Format:

                %d de [[months?parameter=%m]] de %Y

                Done
                  • 3749
                  • 24,544 Posts
                  I think you could also have used PHX in the TV tag without writing any PHP code (although your method is probably faster and more efficient). It does complete date formatting.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 1800
                    • 52 Posts
                    Its always good to hear people praising MODx laugh
                      Minneapolis Web Design <-- where i work
                      MODx Templates <-- new project im working on