0

Is is possible to get custom field data of a calendar from a related event? Basically I want to be able to assign colors to calendars as a custom field, and then within the {events} variable pair set the background color of an event based on which calendar it belongs to. So something like:

{exp:calendar:cal date_range_start="year-month-01" ... }

  {display_each_day}

    {date format="%J"}        

    {events}

      <article style="background-color: #{calendar_color};">
        <h1>{event_title}</h1>
      </article>

    {/events}

  {/display_each_day}

{/exp:calendar:cal}

The above code will only output a blank string for the {calendar_color} custom field (I assume this is because the {exp:calendar:cal} tag by default will output multiple calendars).

So basically I'm just looking for a way to create a reverse relationship from the event to the calendar based on the relationship that is already setup between calendars and events with Solspace Calendar.

1 Answer 1

1

Yes you can call relationships inside calendar events. You need to follow the correct syntax just as if this were a regular calendar:entries tag. ref http://ellislab.com/expressionengine/user-guide/modules/channel/relationships.html

1
  • Does this actually work for you, @pseudoclass? I'm assuming your {calendar_color} is a custom field in your Calendar channel. And events are related to a Calendar, but not through an EE relationship... so what syntax do you use to output {calendar_color} from within an {exp:calendar:cal} or {exp:calendar:events} tag? Commented Oct 9, 2015 at 20:08

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.