Skip to content
This repository has been archived by the owner on May 15, 2018. It is now read-only.

Auto element ID collection - PoC #2

Open
ostark opened this issue Sep 11, 2017 · 8 comments
Open

Auto element ID collection - PoC #2

ostark opened this issue Sep 11, 2017 · 8 comments

Comments

@ostark
Copy link

ostark commented Sep 11, 2017

Hi Josh

Don't know how to start.. but what I did so far:

I played around with Craft 3 Events to collect element ids (excluding MatrixBlock elements). On the backend side I created some listeners to understand update Events.

You can simply put the event listeners in your app.php in your config folder to play around with it:
https://gist.github.com/ostark/020d4dbefe71dfe107b580b80a91e8cf

Not sure if this is useful for this plugin at all as you target Craft 2.

--

Did you make any progress with the Cache driver abstraction?

@joshangell
Copy link
Owner

Thanks Oliver, this looks great! It’s something along the lines of how I imagined it would work in C3, in C2 there aren’t the same events so we have to hook into the BaseTemplate class like the core template caching does ...

The current site I’m developing this on is getting close to having its infrastructure set up so I’ll be finishing off the basic setup this week, which should give me a starting point for the cache driver interface. I’ll let you know!

@ostark
Copy link
Author

ostark commented Sep 11, 2017

The elements.onPopulateElement event in C2 feels similar to the C3 ElementQuery::EVENT_AFTER_POPULATE_ELEMENT event . Maybe this way you can avoid the BaseTemplate.php core hack.

@joshangell
Copy link
Owner

I could, and indeed went that route first, but there is no way of knowing when the template has finished parsing ... so it felt a little shaky to me. Tying in to BaseTemplate.php means I can guarantee I have all the element IDs used in a given requests rendering cycle.

@joshangell
Copy link
Owner

Much like you are doing in your C3 version by listening to View::EVENT_AFTER_RENDER_PAGE_TEMPLATE

@ostark
Copy link
Author

ostark commented Sep 13, 2017

I toyed around with the cache abstraction and had some ideas for structuring the config.

The Event listeners are WIP.

Is that the same direction you want to go?

@joshangell
Copy link
Owner

Thanks for this Oliver, I like your approach.

What is your thinking behind the include/exclude routes?

I am planning on doing more work on this C2 version tomorrow / Friday so I will keep you updated with how that goes here.

@ostark
Copy link
Author

ostark commented Sep 13, 2017

I'm glad you like it :-P

Regarding incl/excl routes:
I'm not sure if the config.php is the best place, but somewhere we must control cache (expire) headers.
An alternative is twig.

@ostark
Copy link
Author

ostark commented Sep 19, 2017

did some refactoring at my end today:
https://github.com/ostark/falcon-craft3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants