问题
What I want to do
I want to have templates tied to a page that can have varying amounts and kinds of data within it.
So template a can have a list or just body content or a special layout.
I want part of this content to be editable from the frontend using create.js. So the page title, the body content, ect would all be editable and need to be saved somewhere (mysql) and somehow. I do not want the content edited in one big WYSIWYG editor.
Similar Functionality but not quite Wordpress allows for tying custom data to a post via post meta.
Drupal does this by defining fields and tying them to nodes somehow.
I am using cakephp to build this site but I am having a hard time wrapping my head around how to save and retrieve this data in a simple understandable way.
I have tried searching for a solution but I don't really know exactly what I am asking is called.
So in summary I am using cake 2.3, create.js (which has backbone and underscore and VIE) to build pages that can be saved to a database but have varying amounts and styles of editable areas. These pages will be administered in the same environment they are displayed.
The goal here is to give the end user some editing without compromising the design. I am asking for good resources so I can research this subject further. Libraries or examples of this in the wild would be great.
Similar question. Database structure and associations for open-ended data and data types
回答1:
For cakephp this looks to be an excellent solution.
http://debuggable.com/posts/unlimited-model-fields-expandable-behavior:48428c2e-9a88-47ec-ae8e-77a64834cda3
Updated version for cake 2.3
https://github.com/zeroasterisk/CakePHP-Expandable-Plugin/blob/master/Model/Behavior/ExpandableBehavior.php
来源:https://stackoverflow.com/questions/17983137/saving-data-with-varying-keys-and-values