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 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条