CodeIgniter Forums
Variable layout (blocks) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Variable layout (blocks) (/showthread.php?tid=9976)



Variable layout (blocks) - El Forum - 07-15-2008

[eluser]codex[/eluser]
There's a few sites where you can alter the layout or sequence of layout blocks on a page via AJAX/drag 'n drop. What is a good way to keep track of the new positions? I'm sure it has something to do with reordering the blocks in the database, but maybe this is done differently, or maybe someone has a better idea.

I'm talking about for instance iGoogle.


Variable layout (blocks) - El Forum - 07-15-2008

[eluser]Colin Williams[/eluser]
Just have a table that manages sorting for different contexts. Contexts could be many things, but in the case of something like iGoogle, the context is the specific user who is viewing it.

You table might look like

context_id | object_id | x_weight | y_weight

Where object_id is a reference to the object being sorted, x_weight determines row (if needed) and y_weight determines column (if needed)

Then, say the user is the context, you would have a user_context table to link them, like:

user_id | context_id


Variable layout (blocks) - El Forum - 07-15-2008

[eluser]codex[/eluser]
[quote author="Colin Williams" date="1216139070"]Just have a table that manages sorting for different contexts. Contexts could be many things, but in the case of something like iGoogle, the context is the specific user who is viewing it.

You table might look like

context_id | object_id | x_weight | y_weight

Where object_id is a reference to the object being sorted, x_weight determines row (if needed) and y_weight determines column (if needed)

Then, say the user is the context, you would have a user_context table to link them, like:

user_id | context_id[/quote]

That's about what I had in mind. Thanks.
Still have to think about how the blocks (or partials) are actually linked to the object_id. What I'm aiming for is a layout that is configurable entirely in the backend, without ever having to touch a template (just the css). I wonder if that's possible. I think it is, but haven't found the right approach yet.

Suggestions are welcome.