0

I am encountering a strange (to me, but maybe I'm missing something) bug when attempting to use conditionals to distinguish between users in the Solspace Calendar tag. As you can see from the code below I'm attempting to display a different calendar dependent on the user's member_group (I have also tried group_id to no avail).

{exp:calendar:cal
    {if segment_3 == ''}
        date_range_start="year-month-01"
        date_range_end="year-month-last"
    {/if}
    {if segment_3 != ''}
        date_range_start="{segment_3}-{segment_4}-01"
        date_range_end="{segment_3}-{segment_4}-last"
    {/if}

    {!-- Main problem from here down --}
    {if member_group == 1}
        calendar_id="1|2|3"
    {if:else}
        {calendar_id="1|2"}
    {/if}
}

The above is essentially what I believe the code should look like. I have tried many different methods including:

  • the same style of {if}code{/if} {if}code{/if} as the segment_3 above it (which works for the segment_3 bit)
  • enclosing the entire tag within a conditional checking the member_group
  • making the conditionals around segment_3 more specific to only allow certain member_groups
  • using quotes on the member_group like so: {if member_group == "1"}
  • putting the member_group check above the segment_3 check
  • Taking out the if statement for segment_3 and only having one on member_group
  • probably various other things that I forget at the moment

When the conditionals are set up like either case of the example above, it will always use the second case. So if I make "1|2|3" the calendar_id for the else statement, that is what it will display.

I have checked to make sure that I am getting proper values from the member_group/group_id by using conditionals with them just outside of the calendar tag and these work properly. Do I just not have access to them within the calendar tag?

Thanks in advance for any help!

1 Answer 1

0

I would change {if member_group == 1} to {if logged_in_group_id == "1"}

If that doesn't work, then perhaps also try changing:

{if member_group == 1}
   calendar_id="1|2|3"
{if:else}
   {calendar_id="1|2"}
{/if}

to:

{if logged_in_group_id == "1"}
   calendar_id="1|2|3"
{/if}
{if logged_in_group_id != "1"}
   {calendar_id="1|2"}
{/if}

I think depending on which version of EE you're using, there was a time (around EE 2.7 I believe) when {if:else} would not correctly work inside a template tag call due to parse order. :)

1
  • The switch to "logged_in_group_id" did the trick! Many thanks for your help
    – K. Matt
    Nov 1, 2016 at 15:03

Your Answer

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

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