We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27519
    • 275 Posts
    The calendar is made up of two components - one for the backend and one for the front end, each with different capabilities. I'll have to dive into the code again to refresh things... I have attached a screenshot of a draft version of the front end as well. Both source their data from the same database tables (obviously).

    I'll get back to you with some info...
      MODx Revolution / MAMP / OS X
      • 33968
      • 863 Posts
      Thanks, I really appreciate this. It's the back end calendar component I'm really interested in...
        • 27519
        • 275 Posts
        The backend component is built basically by copying and extending existing MODX manager components and tweak them to my specific needs.

        The calendar uses a main panel with a subpanel for each month. You should be able to figure out how to do that from the various examples that float around. The month panel (also a standard component) is capable of handling a month object and laying out the days for that specific month attaching specific styles based on availability etc. You will need to keep track of info on change over days, short breaks, allowed start and end days of lets. I implemented an object model for that in PHP (using the MODX framework) and translated my PHP objects to JSON structures.

        So, nothing really new. At this point in time I cannot release any code, mainly as there's another party involved who might object to this. I will probably release it some day but not now.

        Don't know what environment you use but I found developing with ExtJs impossible without a decent debugger (something like Firebug or the Chrome equivalent) and a PHP capable environment. After struggling a lot, I ended up with NetBeans. You need this as you will be passing around JSON structures.

        Hope this helps.
          MODx Revolution / MAMP / OS X
          • 33968
          • 863 Posts
          Thanks for that - I'm familiar with panels/subpanels and have done quite a bit of work with ExtJS within the MODx realm.

          But I have no idea where that month panel is as a 'standard component' - do you mean standard ExtJS component or is it buried in the MODx code somewhere? I haven't been able to turn anything up after searching my filesystem or Google. The only thing I turned up was your old forum post in fact smiley
            • 27519
            • 275 Posts
            Might be some confusion here. There are two panels: one is the date selection panel. This opens up when the user clicks on a date field (e.g. a date picker). I modified the default ExtJS date selection to show booked / available dates when the users picks a date. I remember it being a royal pain in the behind to get it all to work.

            The second is the month panel which is a subcomponent of the backend calendar. The calendar is made up of 4 instances of a month panel, each panel bound to a specific month, where a month object "knows" about its bookings, availability and rates. If I remember correctly, this is also done a subclass of the standard ExtJS (sub) panel. As the user clicks the forward and back buttons, different months get assigned to the four panels and they update their display.
              MODx Revolution / MAMP / OS X
              • 33968
              • 863 Posts
              I'm just trying to understand how you got that nice rendered month display, the second one you mentioned above - is that some variation of this Calendar component discussed on the Sencha blog? The screenshot is broken there but if it's what you've used in your CMP then that would be perfect for me.

              Thanks for your patience!
                • 27519
                • 275 Posts
                No, it's not. They are basically standard ExtJs panels. Their content is server side generated HTML, using tables as that's easier for this kind of layout problem. HTML is generated by a PHP Calendar class.

                The PHP Calendar class has a renderer class associated with it. Actually, if I remember correctly there were two render classes; one for the admin backend and one for the frontend as they had to support different environments and had to generate different server calls based on user interaction.

                The HTML for the backend is acquired via a custom action call in ExtJS to the PHP Calendar class. It is actually a trivial implementation in ExtJs. The meat is in the PHP code that renders the layout and does all the calculations re availability, bookings, rates etc.
                  MODx Revolution / MAMP / OS X
                  • 33968
                  • 863 Posts
                  Ah, that all makes perfect sense - I see how you did it now. I'm much more comfortable doing something like that with a PHP class, although there might be some limitations if any real-time modifications to the calendar are required.

                  This might be a useful start for an events calendar package, I might start another thread on the topic once I've had a chance to tinker with it. Many thanks for the insight!