Subtracting Results of one Widget from Another

I want to have two widgets on a page:

  1. A featured public events widget that shows events that are in the current group, curated by editors in that group through sharing/copying.
  2. A “other public events” widget that lists all other upcoming events not already included in the first widget.

What I wish I could find is something like Stream widgets, but subtracting one from another than adding together. Otherwise, the best I can imagine doing is an include widget (and/or custom module) with two database calls with the specific rules, compare the result arrays, and print it out from there.

Are there any creative solutions for this “list some, then remainder” problem floating out there?

Thanks,
Nick

@mischlern Is this what you need?

I think that is intended to do exactly what you are asking for.

2 Likes

Jon’s nailed it! That’s exactly the purpose of exclude_duplicates. (Note for general use: it’s CMS only because it needs to “know” everything else on the page, which isn’t so with embedded LiveWhale Calendar widgets.) The “added to each widget to be tracked” instruction means you’d add <arg id="exclude_duplicates">true</arg> to both your featured and “other public events” widgets.

I remember seeing this option once long ago and filing it in the back of my mind. Guess all I got from it was a vague prompt to ask.

I tried it, and I stumbled on a bug/feature: this argument doesn’t account for linked copies of an event. When I tried to repeat a widget on a page, some events would appear once, others multiple times before they would fall off. I eventually identified that the number of times was related to the number of linked copies across the site.

My guess is that exclude_duplicates assumes both widgets would be working within group=me or group=xyz, where there should only be one instance (original or linked) of each event. Phooey.

A screenshot showing what I think is happening:


So, this doesn’t work in my case:

  1. Featured events widget is set to be group=me, as a curated list.
  2. Other events widget is set to be group=, to pull all events across the site.

The first widget loads the events in the current group (original or linked) and notes them. Then, the second widget looks around the site and, for each linked event in the first widget, finds the original event to list. (A third widget would then try to find other linked copies, etc.)

If I somehow limited the widgets to only use original events and not linked copies, then the curation through sharing wouldn’t work. We would then need something like tags, which general editors could use/abuse.

And then, thinking some include/custom approach, how would I associate original and linked copies? :melting_face:

Sounds like, for now, I’ll need to go with a simpler approach and let repeats go.

(Though an exclude_duplicates that could accounts for original and linked copies would be great to have…)

Thanks Nick! I’ll file this for our team to look into the exclude_duplicates logic and how it relates to linked copies.

1 Like