PHP / MYSQL - the best way to store data for page layout and content in CMS

I am developing a simple but flexible content manager, and for managing pages I want to give the user the opportunity to organize the layout by dragging the content onto the page, being able to create content lines divided into two or three, like a table.

The following image may illustrate what I mean:

enter image description here

The user can make a layout for a static image on the left, and the text on the right, and at the bottom he can place a gallery of images showing thumbnails.

Now, my question is how to store and load data in Mysql ...

I have two options:

1) With serialized data for the layout:

, , .

:

// Rows / divisions ...
$array[0]['q'] = 2;
$array[1]['q'] = 1;

// The content
$array[0]['c'][0]['t'] = 3;     // 't' = type (3 = image)
$array[0]['c'][0]['i'] = 124;   // 'i' = id to search for this data
$array[0]['c'][1]['t'] = 1;     // 't' = type (1 = text)
$array[0]['c'][1]['i'] = 2;     // Referencia ao ID do conteudo
$array[1]['c'][0]['t'] = 4;     // 't' = type (4 = image gallery)
$array[1]['c'][0]['i'] = 9;     // Referencia ao ID do conteudo

:

a:2:{i:0;a:2:{s:1:"q";i:2;s:1:"c";a:2:{i:0;a:2:{s:1:"t";i:3;s:1:"i";i:124;}i:1;a:2:{s:1:"t";i:1;s:1:"i";i:2;}}}i:1;a:2:{s:1:"q";i:1;s:1:"c";a:1:{i:0;a:2:{s:1:"t";i:4;s:1:"i";i:9;}}}}

:

2) :

"" , /, ;

:

id -> component id
id_page -> page´s id
type -> component type, and 0 == row
value -> id reference to content or quantity of divisions for the rows

:

id / id_page / type / value
1 / 1 / 0 / 2 --> the first row divided in two
2 / 1 / 3 / 124 --> the image
3 / 1 / 1 / 2 --> the text
4 / 1 / 4 / 9 --> the image gallery

, , , , ? , ?

, - .

!

+4
1

, - , .

element_id | serialized_data

element_id, 1- _ ​​ .

0

All Articles