I'm using Mo' Variables for the early-parsed request variables. Here is the best-case scenario:

    date_range_start="{if get:start}{get:start}{if:else}today{/if}"
    date_range_end="{if get:end}{get:end}{if:else}6 months{/if}"

This obviously doesn't work do to advanced conditionals being parsed late (sigh). So here is the workaround I thought might work:

   date_range_start="{if get:start != ''}{get:start}{/if}{if get:start == ''}today{/if}"
   date_range_end="{if get:end != ''}{get:end}{/if}{if get:end == ''}6 months{/if}"

This doesn't work either. After doing a bit of debugging, it appears that the conditionals are not being parsed. My guess is that this is because there is no query string variable called "start" when the user first visits the page so the template parser doesn't find the conditional until later in the parse order.

I can make this work with PHP, but I'd love to have a pure EE solution:

   date_range_start="<?= !empty($_GET['start']) ? $_GET['start'] : 'today' ?>"
   date_range_end="<?= !empty($_GET['end']) ? $_GET['end'] : '6 months' ?>"

So my question is this: is there an elegant solution to---without using PHP in my template---get the value of a request variable and if it doesn't exist use some default value? There must be some trick I'm not seeing to make this work. I don't think using Switchee or IfElse will be elegant here. It will work, but it would look really janky and make the calendar module tag hard to read. I'll concede defeat and drop down to PHP before doing that.

  • Are you open to passing data (your start and end parameters) to an embed where you loop through your calendar? Or are you wanting to avoid that?
    – Alex Kendrick
    Commented Dec 13, 2012 at 16:25
  • Ah ha! Now there's an idea. I'm already using this template as an embed. I was going to convert the parameters I'm passing to Calendar to embed parameters later but if I do it now, it should work because embed variables are parsed early. You should make your comment an answer. Commented Dec 13, 2012 at 16:33

1 Answer 1


One option is to set your Mo' Variables and pass them to an embedded template where you loop through your calendar.

So you could do:

    start="{if get:start != ''}{get:start}{/if}{if get:start == ''}today{/if}" 
    end="{if get:end != ''}{get:end}{/if}{if get:end == ''}6 months{/if}"

And then in your embedded template:

    {!-- calendar stuff here --}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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