We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4622
    • 2 Posts
    Hi everyone,

    I am in the process of making an Event Calendar snippet (a re-worked version of Kalender) which I plan to share with everyone when complete. But I’ve run into a problem.

    If you’re not familiar with Kalender, it uses the publish and un-publish dates of a document to set the calendar dates for an event.

    Where document [*content*] exists for an event, I’ve got the calendar dates linking through to the relevant page id.

    However if the date of the document/event is set either side of ’legal’ publish dates, of course the document content can’t be displayed and the visitor is returned to the default page.

    Because event dates can obviously fall anywhere in the year, I need to somehow force un-published content to be shown, ideally through the href url.

    eg. href="index.php?id=23&ignorePublishDates=1" smiley

    Is there any such feature - or does anyone have any suggestions?

    Many thanks in advance!
    Carl.
      • 7923
      • 4,213 Posts
      Why not use TV’s for the event dates?


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 4622
        • 2 Posts
        Thanks for the lead. Am _very_ new to modx so still getting to grips with it!

        I was hoping I could use ’pub/unpub’ fields purely to make it easier for the client to manage. But yes, I can see it’ll make my life easier to use two dedicated variables for the job. So I’ve created two new TVs, EventStartDate and EventEndDate and assigned them to my ’BaseTemplate’ - currently the only template used by the site.

        In this case, I assume it’d probably be better now to create an ’EventTemplate’ and assign those TVs to that template only, so they’re not selectable for every page of the site? So, rather than completely duplicating my BaseTemplate with the only difference being that EventTemplate will have two TVs assigned, is there some way to ’nest’ these? ie. so that the EventTemplate content uses the same layout?

        Or is the idea to split my BaseTemplate into ’chunks’ and reference these chunks from each template?

        Any advice appreciated - cheers,
        Carl.
          • 7923
          • 4,213 Posts
          For now, you should just put the template code in chunks, or just one chunk if you want.. then use {{chunkname}} in the template code..


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 25663 MODX Staff
            • 12,272 Posts
            Definitely use TVs for event dates too so you don’t run into weird auto-publishing issues.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 7923
              • 4,213 Posts
              Yea, and you avoid issues with things like this..


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."