douba4824 2013-03-22 12:34
浏览 101

灵活的侧边栏数据库设计

In my system I have a flexible layout, where you can place your sidebar left or right (or both). You can add multiple sidebars and then choose which one you want to use for your page, and on which location.

What is the best way to store the items in a sidebar, while maintaining the ability to edit the item configuration per sidebar?

The items consist of a php class in which the config options are passed through to a template file.

My origional thought was to implement some sort of shortcode functionality and add a shortcode to a sidebar_item entry in the database, but this way it wouldn't really be configurable.

  • 写回答

1条回答 默认 最新

  • dsiimyoc804955 2013-03-22 13:11
    关注

    If I understand you correctly, you have:

    • a user, who can place a sidebar where he wants to,
    • a sidebar, that can contain some elements,
    • items, that can belong to each sidebar to each user,
    • files to handle items of different types.

    and every user has his own sidebar with his own content.

    I can propose tables:

    • users in which users are defined by some id,
    • sidebars in which you say which user it belongs to, and if it is left or right,
    • item_types where you say which template and/or configuration files should be used,
    • items in what type it is (from item_types), so you know which template to use, then in which sidebar (from sidebars) it is, maybe what position it is (first, second, ...).

    You should create relations between:

    • sidebars and users on user id so selecting user you could know which sidebar(s) he owns,
    • items and sidebars on sidebar id, so knowing sidebar you know which items are in it,
    • item_types and items on item type so you know how to handle it,

    Perhaps, in items you can also store configuration variables that you could pass to template.

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大