We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38593
    • 129 Posts
    I am a newbie, learning as I go. MODX installed OK, I created a new template, added some chunks and TVs for the template. Tried to create a new document, which works OK ONLY if I use the base template that came with the install.

    If I select my new template from the Uses Template dropdown, it throws up an warning message, asking if I am sure I want to change the template, I select yes, it refreshes the New Document page showing the new template chosen, then a few seconds later it resets the Uses Template back to the Base Template.

    Tried quickly saving as soon as the page refreshes without success, tried saving a page with the Base Template then changing the template later without success.

    I love the potential of MODX but it does not have an easy learning curve for beginners. Any suggestions as to what I need to do to be able to use my own templates instead of the basic Base Template?
      Pedalers Bicycle Tours my website forged with MODX
      vandergraaf-M static website generator for MODX
    • There appears to be a problem with conflicts of time zone settings between MODx, PHP and MySQL.

      http://forums.modx.com/thread/73018/2-2-0-pl2-cannot-change-template-on-new-resource-console-errors?page=6#dis-post-413697
        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
        • 38593
        • 129 Posts
        Thanks, but I haven't a clue as to how to check that nor how to change it if it is wrong.

        Using phpinfo it shows UTC for the timezone, and checking the server settings it was blank, which the note said defaults to UTC. But for MySQL, not sure where to look or edit timezone.

        I did discover by trial and error, that I can create a document using the default template, then using the right click Quick Update, I can change the template for an existing document, but ONLY through the Quick Update, the main panel won't.
          Pedalers Bicycle Tours my website forged with MODX
          vandergraaf-M static website generator for MODX
          • 3749
          • 24,544 Posts
          You can ask your host about the MySQL timezone setting. If you're using MODX Revolution, you can change the MODX date/timezone in System -> System Settings (put timezone in the search box at the upper right).


          ---------------------------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 32316
            • 387 Posts
            Pretty sure I have written this before - so it would be in the 'those previous threads somewhere!

            Here is one way:
            while editing a page - click on the settings tab
            look at the publish date box and the time box next to it - if they are filled in erase them both (after noting the values if you want to put them back.
            now click on the calendar icon and them click on today, this will fill in a date
            now click on the time box it will fill in a time (at least it usually does for me - do not click the arrows, and you get one go at this - though you can start over!) - this time is the mySQL server time and not 'php time'

            the time filled in is obtained from the mySQL database server - now you can go to the System Settings and choose a time zone that matches and your problem should be solved.

            Note that some people seem to have had this problem suddenly appear with daylight savings time changes - since not all places in a timezone observe DST

            Just my way of avoiding asking my host - I have a reputation to maintain! - and of course it is what the server says that is the final word! But it probably is better in some senses to ask your host - still its nice to have a way of checking. You could also write a snippet to return both php time and mySQL time ... I think I did that, I'll look for it.
              • 3749
              • 24,544 Posts
              Great idea. smiley

              BTW, as long as you don't save the resource, you don't have to worry about the existing dates changing.


              ---------------------------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
              MODX info for everyone: http://bobsguides.com/modx.html
                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
              • Actually, that's probably nothing to do with MySQL at all. By default, MySQL uses the system's timezone settings, so it would be dependent on the server's operating system and its configurations.

                http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html
                  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
                  • 38593
                  • 129 Posts
                  Thanks Whistlemaker, I tried your method and MySQL returned my local time so I added that value for the system time and all is good now.
                    Pedalers Bicycle Tours my website forged with MODX
                    vandergraaf-M static website generator for MODX
                    • 32316
                    • 387 Posts
                    Here is a simple snippet for testing that will display
                    1 - what time php thinks it is
                    2 - what time mySQL thinks it is
                    3 & 4 - what timezones are set for the mySQL server and session (if different)
                    It assumes you have not moved the core.

                    //get the values we need to log into the mySQL server with
                    include 'core/config/config.inc.php';
                    
                    //php date
                    $arr['php'] = date("F j, Y, g:i a"); 
                    
                    //mysql
                    $link = mysql_connect($database_server, $database_user, $database_password);
                    if (!$link) {
                        die('Could not connect: ' . mysql_error());
                    }
                    if (!mysql_select_db($dbase)) {
                        die('Could not select database: ' . mysql_error());
                    }
                    //get the mySQL time
                    $result = mysql_query("SELECT NOW();");
                    if (!$result) {
                        die('Could not query:' . mysql_error());
                    }
                    $arr['time'] = mysql_fetch_array($result);
                    
                    //returns the system timezone.
                    $result = mysql_query("SELECT @@system_time_zone;");
                    if (!$result) {
                        die('Could not query:' . mysql_error());
                    }
                    $arr['systimezone'] = mysql_fetch_array($result);
                    
                    //returns the session timezone if it differs from the system timezone.
                    $result = mysql_query("SELECT IF(@@session.time_zone = 'SYSTEM', @@system_time_zone, @@session.time_zone);");
                    if (!$result) {
                        die('Could not query:' . mysql_error());
                    }
                    $arr['sestimezone'] = mysql_fetch_array($result);
                    mysql_close($link);
                    
                    $times = 'php time is: '.$arr['php'].'
                    ';
                    $times .= 'mySQL time is: '.$arr['time'][0].'
                    ';
                    $times .= 'mySQL system timezone is: '.$arr['systimezone'][0].'
                    ';
                    $times .= 'mySQL session timezone is: '.$arr['sestimezone'][0].'
                    ';
                    
                    return $times;


                    Note that at the end of the code each of the lines that start $times should not end .' ' ; but have a br tag between the quotes - the forum removes br tags everywhere!
                      • 38593
                      • 129 Posts
                      Thanks
                        Pedalers Bicycle Tours my website forged with MODX
                        vandergraaf-M static website generator for MODX