A Preview of PyroCMS Page Types
posted 2012-12-03 by Adam Fairholm
For the upcoming 2.2 release of PyroCMS, we've been working on integrating Streams into the pages fields. We went through several revisions of how that should actually work, and we're really happy with where the feature has ended up. The idea behind streams is that a single data system gives a CMS more power to manage and structure content, and page types is a major step towards making that happen in PyroCMS.
2.2 isn't out yet (we should have a beta in the next few days), but I've gotten a few questions about how page types will work, so here's a feature overview.
First off, to see page types in action, check out this quick demo to see it in action. It only took me 14 tries!
What Are Page Types?
Let's say you have a site of products. Each product has its own page. In the past, you would have to create a project display page in the page tree, and then display that product using streams tags. You still may want to do that, but now you have the option of having data entries represented directly in the page tree with page types.
A page type is a layout that is tied to a specific stream, so when you create a page, you fill out the data for a stream entry as well as the page fields. Then, simply use the fields from the page/entry in your layout. No pulling data from the URL necessary.
Plus, your data is still a stream. That means, if you have the streams plugin that comes with the streams module, you can display it in a cycle loop, create entry forms for it, whatever you'd like! We designed page types with maximum flexibility in mind for your content.
What Streams Can be Attached to a Page Type?
Any stream. You can choose an existing stream from any namespace, or the pages module will create one for you (in the 'pages' namespace). Also, multiple page types can use the same stream.
I Already Use the Stream Module. How Would I Use Page Types?
Let's say you are building a website for a business that has a few locations. You want to create a location index, and then have a page for each location. You've got a stream called Locations with all your location fields (address, etc.) and you want a page to display each one.
So, you'd create a page type called Location and choose your Locations stream when creating it. Add in your display logic for how to display the location in Then, when you click New Page, you can choose Location as the page type, and then add in your location data into your location fields. Your location is now both represented in your page tree and in your stream. You can use either the streams plugin or various functions in the pages plugin to list your locations as well.
I Don't Have The Streams Module Installed, Can I Still Use Page Types?
Definitely! When you create a page type, you just select the option Create New Stream for this Page Type. Once you've created the page type, you can create fields right in the Pages module. No streams module needed.
Are Page Types in Community?
Yes, they are. Community has the Streams Core module and the Stream API which allow modules to integrate streams in the community version as well as Pro. Page types is a PyroCMS Community feature.
What About Chunks and Page Layouts?
The migration from page chunks/layouts to page types is pretty simple. Page layouts become page types and are all assigned the default page stream, which has one field. That one field houses all of your chunks. So in short, your chunks will still be in tact. We recommend moving off of chunks, but they will still work.
Anything Else Fun I Should Know About?
Yes - several new features were created during the page type development process:
- Through a new Event in 2.2, you can enable a field_types folder for your module where you can put module field types.
- You can now save page type layouts as files. It will also save the page type CSS and JS as files.
When Can I Try It?
We're still testing internally, but a beta should be available later this week. Until then, feel free to ask questions on this post!