We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37859
    • 34 Posts
    I want to display store hours on a website I'm creating.
    I'd like to integrate the following php class https://github.com/coryetzkorn/php-store-hours, but have no idea how to do this.
    Think I must use a snippet, but never created a snippet before.
    Anyone willing to help me ?
      • 3749
      • 24,544 Posts
      See if this helps: http://bobsguides.com/modx-snippets.html

      In this case, I think what you want to do will start with this file: https://github.com/coryetzkorn/php-store-hours/blob/master/index.php.

      Put the php code between the opening and closing php tags (not including the php tags) into a new snippet. Change any 'include' or 'require' lines in the snippet to the actual path of the file. You can use the constants (MODX_ASSETS_PATH, MODX_CORE_PATH, etc.) in the path.

      Change *all* echo and print statements to add to the $output variable and return $output at the end of the snippet -- like this:

      $output = "";
      // echo 'Some output' 
      $output .= 'Some output';
      
      // echo 'Some More Output';
      $output .= 'Some More output';
      
      return $output;


      Move any CSS to your template, a CSS file, or the content section of the resource. Do the same with any necessary HTML code.

      Put a snippet tag for the snippet you created at the place in the page where you want the output to appear. Normally, you would use snippet properties to control the snippet's behavior, but in your case, I think all the configuration is done by modifying the snippet code.
        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