Skip to main content

Automating the puzzle embed process

Objective

Learn how to automate the process of publishing individual puzzles, without using an embed code each time

Load puzzle by Date

You can load a puzzle by providing its publish date. When using this embed method, the id parameter must not be present in the iframe URL. Instead, a date parameter must be present. The date format used for fetching the puzzle is: YYYY-MM-dd.

date=YYYY-MM-dd
  1. If you are using a time zone other than UTC, it can be specified through the URL param 'timezone'. For example: timezone="America/New_York". We can also pre-configure the time zone for a given series. The default time zone is UTC.
timezone=TimeZoneID (optional)
  1. If there is more than one puzzle in a series that falls within the specified time window, the latest one is loaded in the iframe.
  2. If there is no puzzle published in the specified time window, an error page is returned, indicating that no puzzle is available.

For example, if you would like to get a puzzle published on Feb 6th 2023, you can query the puzzle with the URL parameter: date=2023-02-06. A puzzle that was published between 2023-02-06 12 AM and 2023-02-06 11:59 PM as per the set time zone is returned.

https://cdn2.amuselabs.com/pmm/crossword?date=2023-02-06&set=sample-crossword&embed=1

Where to use this

This approach works best for a daily or weekly puzzle that is published at a regular interval and if the puzzle has its own dedicated page which is identified by the date.

Date based puzzle ID

In this approach, the planned publish date of the puzzle is represented as part of the puzzle ID. The puzzle ID is made up of two parts - a prefix and the publish date for the puzzle. The prefix varies for each puzzle series. The date is represented using the YYYYMMDD format. The format of the ID is:

prefix_YYYYMMDD

New puzzle files uploaded to PuzzleMe are required to use the above specified ID for their file names. For example, the XML file intended to be published on 29th July, 2022 for the Sample Crossword series (with prefix sample-crossword ) should be named as:

sample-crossword_20220729.XML

Once this XML file is uploaded, PuzzleMe will automatically set its publish date to 29th July, 2022, and set its ID to sample-crossword_20220729 . This ID can then be used to refer to and embed this puzzle. Once uploaded, the ID of a puzzle file named in such a format is not changed.

Where to use this

This approach works best when puzzles are published with a regular cadence.

  • This approach is recommended for puzzle archive sections, as well as for pages where the parent page title/URL would be predictable and known beforehand. In such cases, once the puzzle ID is calculated and set in the embed code, the embed code does not need to be updated further.
  • This approach could also be useful for puzzle section landing pages, where the design would require embedding the latest N published puzzles. However, the IDs of these latest N puzzles would need to be updated, in accordance with the new puzzle publishing schedule.
  • This approach can also be used to predictably generate the PuzzleMe WordPress plugin shortcode. In the sample shortcode below, the value of the id is generated based on the formula described above.
[puzzleme set="crossword" id="sample-crossword_20220709" type="crossword"]

Index based puzzle ID

note

This approach can be used to load a specific puzzle directly. However, the embed has to be routed via the date picker, i.e. the solvers will always have the option to go back to the picker from the puzzle.

In this approach, a specific puzzle is referred to using its index, i.e. its position in reverse chronological order, of all the puzzles present in the given series. The most recently published puzzle in a series is denoted by index 1, the puzzle published before it is denoted by index 2, and so on. For example, if 4 puzzles - A,B C and D are present in a given series, and have their publish dates set to 10th, 11th, 12th and 13th of the month respectively, then each of the puzzles will be referred to using the index 4, 3, 2 and 1 respectively.

The index is specified using the idx parameter. When a puzzle is loaded using this parameter, the puzzle id does not need to be specified. For example, the iframe URL for the first puzzle in the sample-crossword series would become:

https://cdn2.amuselabs.com/pmm/date-picker?idx=1&set=sample-crossword&embed=1

The index of a puzzle can change if puzzles are added to or deleted from the series, or have their publish date and time modified. For example, If a new/existing puzzle’s publish date/time is set after a specific given puzzle, then the index of the given puzzle would increase by 1.

Where to use this

  • This approach is useful for puzzle section landing pages, where it would be required to link to/embed the latest N published puzzles. As new puzzles are added to the series, the puzzles denoted by the existing indexes will change, and solvers will be able to access the latest puzzles.
  • This approach is NOT recommended for puzzle archives, or puzzle embed pages that have unique titles/URLs, since the index would need to be updated in all existing puzzles' embed codes, each time a new puzzle is added to the series. In such cases, the date based ID approach should be used.
  • This approach is currently unavailable for the PuzzleMe WordPress plugin.