Page Parts of Different Types
|
486 posts
|
It would be cool if as part of the creating new page part dialog, we can not only set the name of the page part but also it’s type: integer, date, string, text (default). I know the page_part table would need to handle this, perhaps via Single Table Inheritance? I had thought originally of extending the Page model but then realized that all the action is in the page_part table… If we can do this, then truly Frog would be supremely powerful :) 0.9.5? |
|
486 posts
|
And wouldn’t it be great if once you select the date data type, the Part that is generated is a Javascript date picker widget. If you select integer data type or string data type, you get an input box instead of a textarea… |
|
184 posts
|
Couldn’t you do that with type casting: <?settype($myVar, “string”);?> |
|
316 posts
|
I’m confused, why would you want to change a page part type? It is meant to be “page” what would be the purpose in changing it to type integer? The page parts are stored as part of the Page and PageArchive objects, they aren’t variables per se, they are class objects. |
|
486 posts
|
Page parts are actually Pages? I think it would be useful because Parts are often used essentially as form elements. By giving data types to Parts we can essentially create on-the-fly forms, which would enable custom content types (pages with certain combinations of Parts) without the hassle of actually extending the Page model. Page parts with specific data types would be easier to manipulate. Dates are one example. If a page Part can be specified as a date type, then we could get from that both manipulation of dates (for sorting, differences, etc) as well as an appropriate way for the user to input the data. Right now if you want to enter a date into a page Part, you just have to trust the user to enter it in a certain format that you can parse. The user is never actually going to remember whether they’re supposed to enter it as YYYY-MM-DD or MM-DD-YY or whatever, so it’s not ideal. That’s why we like to use Javascript date pickers. |
|
316 posts
|
If you are concerned about Dates and times, wouldn’t it make sense to pass the, I’m assuming, form value through strtotime()? EDIT: Or better yet, set 3 different inputs that you control. Input for Day, Input for Month, Input for Year and then pass it through to mktime()? |
|
486 posts
|
If I’m not mistaken, you’re saying a separate Part for each section of the date. That would help, but I think you’re still going to have validation errors because of misspellings and so forth (and of course separate Parts is inelegant to say the least). And because the date is still stored as text in the database, you’re still limited in what you can do with it. Let’s just ignore dates though. The basic thing I’m saying is that there are different data types in programming and we store different data types in a database for a reason. It would be nice, simply, if we can extend that and get the power that comes with it to Frog’s Page Parts system. |
|
316 posts
|
A separate part for each? I’m really confused now. A page part is the section in the Admin’s Page Editor usually named “Body”. You add extra page parts by clicking the “+” on the right hand side of the edit page. If you have Body and Extended, you have 2 page parts. All my pages have 3 page parts, Body, Extended, and Summary. Anything you write in the editor box is stored within that page part. Why would you create a different Page Part for that type of form? EDIT: Here is a screen capture of my backend to show you what I mean.
|
|
1493 posts
|
I suppose anything is possible … but I’m also pretty clear that we’re doing some “thinking out loud” about post-1.0 release enhancements! Or maybe this is something that could be handled by a plugin? What I’m having a hard time picturing is the structure of the db table. Here’s the page_part table as it is at present:
To accomodate the sort of flexibility that ricks is after, I assume one would have to add not just new fields to this table, but whole new tables to accomodate different data types. Now database design is hardly my long suit, so I may be way off on this! I suppose you could have something like the following:
And then you would also have three corresponding tables… I don’t know! Just me thinking out loud is all….. |
|
1493 posts
|
P.S. Ricks wrote in post #5 (up there somewhere!):
“Body” is just the default page-part. The “Page” table only holds the “page’s” metadata; its content is wholly contained in the “page-part” table. But I’m guessing you knew that already. |
|
316 posts
|
Sorry, this is probably going to be fairly long, but it might help to explain how the Page Parts are saved in the variables. If you go down this print out of one of my archives, you’ll see the “Parent > Page Object” and then eventually you hit “Part > Body” etc. Each page part is a stdClass Object, not a variable, per se.
So, for example, near the very bottom, you see
That “summary” is the name of the page part, it is repeated just inside the object.
That section is the contents of the page part, where you store the contents of your page. The only way, I could see, of changing that would be to add another section after name of type. But I still don’t see why you’d need that. Everything is manipulable via code or plugin and that’s far easier than changing the framework, I think. |
|
651 posts
|
@everyone… Maybe this is a stupid remark, maybe not… anyway, here goes: It sounds like you’re all trying to develop a solution to a problem. It also sounds like the problem isn’t really clear to all of you, at least not in the same way. May I suggest a different tactic to tackling this? I would like someone to describe a so-called “user story” for this problem. A user story basically is an explanation of what the user wants to do without describing how he wants to do it. This should allow the developer to present a technical solution which hopefully does what the user wants. An example of what I mean:
another example would be:
What do you think about trying it this way? Then the techies could formulate a consistent, light-weight, in-keeping-with-Frog-style solution. |
|
1493 posts
|
@mvdkleijn: I think that’s brilliant! You do get the feeling that sometimes in this thread we’re talking past each other. The other observation I would add is that Frog won’t always be the best tool for every job. (Hard to believe, I know.) There are other CMSs whose main raison d‘être is to provide a means of manipulating databases. But that ain’t Frog, IMO! :) |
|
486 posts
|
Thank you for indulging me, guys. As David said, this is really a “thinking out loud” sort of thing. Your input and comments helped to clarify my thoughts, and I think David’s final comment about Frog not being designed for databases is probably correct. mytylerb’s example of Page Parts usage is probably as far as you should stretch the Parts system. Instead of using the Parts system, I’m thinking now that things like Events should be built outside of Frog’s Page system but using the Framework, and still integrating with Frog so that you can still have a tab in the dashboard for adding Events. By staying completely out of the Page system (and Parts), you can have perfect forms (radio buttons, inputs, dropdowns, etc) use your own tables and data types and have complete control over the data. It would be easier I think than trying to use the Parts system to accomplish this. So you can still have a site like this: frogsite.com/events, but now events would be a controller outside of Frog, but still within the Framework. It would not generate pages that would appear in the pages listing. Does this sound like a better idea? And has anybody done something like this where you use Frog for the general CMS but extend it further using the Framework (with content outside of the Page system) in order to meet requirements? |
|
316 posts
|
I think I think out loud too much. ;-) I believe this all started with a want by chaichai for a calender plugin. |
|
651 posts
|
I think you’re on to something there ricks ;-) Remember… the controllers you create using the plugin API are effectively controllers from the Framework. All you need to do for an event system is write a small plugin which has:
That way, end-users can simply use the various functions to create, read, update and delete events and create their own interfaces on the frontend. |


