1
  • EE 2.10.1
  • SolSpace Calendar 1.8.14

If I have an event on the 2nd and 4th Wednesdays of every month, how can I programmatically convey that recurrence rule in plain English? I know Calendar provides the {rules}...{/rules} tags inside {exp:calendar:events}, but the variables provided therein don't convert to English very easily.

Here's what I've come up with so far. It's not comprehensive by any means, as all it does is convey the specific recurrence rule I mentioned earlier in English—it's not flexible enough to handle many variations (it doesn't account for if a new rule is an exclusion, it assumes recurrence is monthly, etc).

<p>Schedule:
    <ul>
    {rules}
        <li>
        {rule_relative_dow backspace="2"}
            {if "{relative_dow}"}
                {relative_dow}<sup>{if "{relative_dow}" == 1}st
                {if:elseif "{relative_dow}" == 2}nd
                {if:elseif "{relative_dow}" == 3}rd
                {if:elseif "{relative_dow}"}th
                {/if}</sup>
            {/if} &{/rule_relative_dow}
        {rule_days_of_week backspace="2"}{day_of_week}, {/rule_days_of_week}
        of every {if "{rule_repeat_months}" > 1}{rule_repeat_months} months{if:else}month{/if}
        </li>
    {/rules}
    </ul>
</p>

I feel like there should be a more concise way to do this...

1

This works for me:

{rules} {if rule_repeat_weeks}Every {if rule_relative_dow}{rule_relative_dow backspace="2"}{if '{relative_dow}' == '6'}Last{/if}{if '{relative_dow}' != '6'} {exp:ordinal}{relative_dow}{/exp:ordinal}{/if} & {/rule_relative_dow}{/if}{rule_days_of_week backspace="2"}{day_of_week}, {/rule_days_of_week} {/if} {if event_all_day} (all day){if:else}at {rule_start_date format="%g:%i%a"}-{rule_end_date format="%g:%i%a"}{/if}
{/rules}

Get the Ordinal Suffix plugin free on Devot:ee

3
  • The plugin link on Devot:ee appears to be broken... :( – Sandwich Nov 13 '16 at 14:37
  • I would be happy to email it to you if you tell me where to send it. – Debra Dec 4 '16 at 23:35
  • sandwiched at gmail dot com is fine, thanks! – Sandwich Dec 5 '16 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.