a-digital / eventbrite

Craft 3 plugin to interface with Eventbrite data through its API.
Other
2 stars 2 forks source link

Can I access the other event IDs? #15

Closed dcplebranch closed 10 months ago

dcplebranch commented 2 years ago

Is there a way in my twig template to access the list of "Other Event IDs" that are entered under the Eventbrite settings?

mark-adigital commented 2 years ago

Not currently, no. There's the option to return just the 'other' events using craft.eventbrite.otherEvents() and you could potentially iterate over those events to get their IDs, but I can't say a use case for returning just the IDs entered for other events is immediately clear to me? It wouldn't be overly complex to add, but I'm struggling to see how being able to retrieve just the numerical values for that setting would be that useful?

dcplebranch commented 2 years ago

Hey Mark, thanks for the reply. The reason I want this is because I have a template that lists event details... it's basically a route i set up like this /events/{id}... and in the twig template I take this ID and I look up the eventbrite event details (using eventbrite.eventById method) and display it on the page.

The reason I do this is because my client wants to only enter event details once... she doesn't want to have to enter it in craft and again in eventbrite... but we still want all that eventbrite info to appear on the website in its own page. So this way she only enters it in eventbrite, but she also gets a page on her website for that event.

The problem comes in when I enter /events/{id} where the ID is one that's not from our organization NOR is it on the "other IDs" list... the page still renders with full details and everything, as if it's one of our events. I don't know why it does, but it does. So I was thinking I could test to see if the ID is one of our events or one from that "other IDs" list before rendering, and if it's not, then I can say "event not found".

That is the reason I'd like access to the other IDs list. I'm sure there are other ways of doing this, for example running an allEvents() query and building a list of valid IDs, then checking the requested ID against that array of IDs... but that seems very processor intensive and is an extra SQL statement, so...

mark-adigital commented 2 years ago

Thanks - that makes sense, and I think understanding the issue now there's a better fix I can apply for this. The base problem is that the eventById() method retrieves any event from Eventbrite via the API; there's no checking that the given event is organised by the relevant organisation or that its ID appears in the 'Other Event Ids' setting.

I hadn't considered that this could happen, and now you've pointed it out I think adding a check to the method so that the organisation ID or event ID must match the plugin settings is the right way to resolve this.

I've just made an update to the plugin which it would be great if you can test out? If you're working with Craft 3, then you can change your adigital/eventbrite requirement in the composer.json file to:

"require": {
  "adigital/eventbrite": "craft3 as 1.0.7",
  "...": "..."
}

Or for Craft 4, it would be:

"require": {
  "adigital/eventbrite": "master as 2.0.1",
  "...": "..."
}

Then run composer update.

That will allow you to get the most recent version of the codebase without me doing a full release, so if you could apply it to a dev site for testing that would be great. Then afterwards just revert the composer.json update and re-run Then run composer update.

dcplebranch commented 2 years ago

Hey Mark,

I'm getting this error from composer:

In VersionParser.php line 521: Could not parse version constraint craft3: Invalid version string "craft3"

mark-adigital commented 1 year ago

Sorry for the delay on this one - I've been advised to use composer aliases by people when reporting issues myself but wasn't sure how to make it work when not referencing the latest commit on the master branch. I've done some reading around and I believe you can get the latest version of the Craft 3 branch by adding dev- as follows:

"adigital/eventbrite": "dev-craft3 as 1.0.7"