When to use stream versus repeater field versus module?Created 6 years ago by gwerner
I'm having some difficulty wrapping my mind around what are probably some basic Pyro concepts. Mostly in the department of when to use a stream, when to use a module or the new repeater field?
Let's say we are creating a home page slider as an example. And, I'd like for this to maintained through the CMS. This example slider will have 3 fields. They are image, html(editor) and url.
Using the old Pyro I would probably have created a new stream to handle the 3 fields and maintained the data outside of the page. And looped throughs the data in the page layout. With new Pyro my first thought is to create a module and maintain the fields there. And then access that module through a new page with an editor field type. Is a module overkill for this?
Now we have the new repeater field which looks like could also handle this? I've just started on a new project and it looks like my home page could use two repeater. When creating a new page and adding two repeaters and then the data for those repeaters the admin for that page can grow considerably.
So, with that said what is a general best practice or smart approach to the example I've outlined above? Any help or guidance is appreciated.
Good question! You will find that Pyro allows you to do the same thing many many different ways. Often times there's now "wrong" way just as their is no "right" way. I've been taught by community members before on how to do things better but I will share with you how I personally would handle this.
Also - everything in Pyro 3 is a stream so I am going to assume by "stream" you mean in the streams MODULE.
Typically, we like to handle as much as we can in pages. So the slider I can tell you right now would be a repeater OR a files field on the home page type. We do use the streams module a lot though. Typically for contact locations, any import data that needs managed.. staff and the likes. If the data is going to be used in MORE than one place.. into streams it goes.
I will build out modules or addons when I need more than simpler data / UI requirements. For example we are doing a site for a placement agency and the "jobs" module has the stream / data structure for the XML import we get FTPd to our server every morning. But the module also has a schedule and some Artisan commands to handle checking and importing / syncing the jobs in the XML file. Also the UI part is read only.
As a rule of thumb.. think about where the data is going to be used. Think about it's input in relation to everything else... and make your best guess! If repeaters would be heavy on a page.. might be a design flaw in your implementation. Rework real quick and clean em out.
Hope this helps!