Event Calendar "GetEvents" Page Association Scope

Topics: General, Standard packages, Troubleshooting
Aug 17, 2011 at 10:26 PM

I have two separate events Calendars on my site. They have different data stores (as Events are always under pages)

The EventTeaserCompact uses the GetEvents function, but I only want it to show events from one of the data stores.

It would appear that Page Association Scope is what I want to change, but I only have "Default" and "Function" as options for the GetEvents Function. I'm running Beta 2. Any suggestions?

--

Gary

Aug 18, 2011 at 1:09 AM

You can introduce a filter on the event's page ID field and have the page ID controlled via a new parameter on the EventTeaserCompact function. I must admit the solution below really isn't very obvious to come by - we should add a better default filtering option to the package.

  1. Edit the xslt function EventTeaserCompact
  2. Add a new 'Input Parameter' named "EventParentPage" of type DataReference<C1 Page>
  3. Set a "Test value" for the new input field - populate that with a call to 'Composite.Data.Types.IPage.GetDataReference' and select a page that have events attached below it
  4. On the 'Function calls' tab, use the function markup shown below (switch to code view, paste in, switch back to visual view)
    <f:functions xmlns:f="http://www.composite.net/ns/function/1.0">
      <f:function name="Composite.Community.EventCalendar.GetEvents" localname="GetEvents">
        <f:param name="eventFilter">
          <f:function name="Composite.Community.EventCalendar.Event.FieldPredicatesFilter">
            <f:param name="PageId">
              <f:function name="Composite.Utils.Predicates.GuidEquals">
                <f:param name="Value">
                  <f:function name="Composite.Utils.GetInputParameter">
                    <f:param name="InputParameterName" value="EventParentPage" />
                  </f:function>
                </f:param>
              </f:function>
            </f:param>
          </f:function>
        </f:param>
        <f:param name="pageSize">
          <f:function name="Composite.Utils.GetInputParameter">
            <f:param name="InputParameterName" value="MaximumEventCount" />
          </f:function>
        </f:param>
        <f:param name="returnInternationalShortDates">
          <f:function name="Composite.Utils.GetInputParameter">
            <f:param name="InputParameterName" value="UseInternationalDates" />
          </f:function>
        </f:param>
      </f:function>
    </f:functions>
    
  5. Save the XSLT and make sure your existing calls to this function gets the new (required) parameter added to it.

What goes on here is that the xslt will now send the eventFilter parameter when calling GetEvents and this is a filter on PageId - a guid value identifying a C1 Page. This ID/Guid is grabbed from the Input parameter you defined. Now, that is of type DataReference<C1 Page>, not Guid as is expected, but automatic type conversion between Guid and DataReference<C1 Page> ensure this work.