表达引擎成员到类别到渠道的关系
可能的重复:
一对多成员到文章关系
我们是新的表达引擎,也许可以使用任何使用此 CMS 构建了一些网站的人的帮助。
我们有一个小型仪表板系统,用户可以登录并阅读其他作者提交的文章。我们希望有一个表单,允许会员在登录时选择他希望在主页上显示哪些类别的文章。然后我们想弄清楚如何实际创建该主页,以便只有用户选择的文章类别是可见的。
从数据库的角度来看,这似乎是用户和类别之间的一对多关系,但我们不知道如何在 ee 内部实现此目的,特别是使用成员,因为它不是通道并且似乎不允许创建成员自定义字段中的关系。
我们考虑为每种类别类型创建一个自定义字段,但大约有 95 个类别类型,当我们添加或删除它们时,尝试跟上所有类别类型将非常麻烦。即使我们这样做了,我们仍然不确定如何将 1 个成员连接到多个类别或通过一个类别连接多个条目。
总之,其想法是,使用登录的成员获取已分配给多个类别之一的文章的快速列表,这些类别已被该登录的成员选择为首选项。
Possible Duplicate:
One-To-Many member-to-articles relationship
We are new to expression engine and could maybe use some help from anyone who has built a few sites using this CMS.
We have a small dashboard system where users log in and read articles that are submitted from other authors. We are wanting to have a form which allows a member to chose which categories of articles he would like to be on his home page when he logs in. Then we'd like to figure out how to actually create that home page so that only the categories of articles that the user has chosen are visible.
From a db standpoint this seems to be a one to many relationship between a user and categories, but we have no idea how to accomplish this inside of ee, especially using the members, since it isn't a channel and doesnt seem to allow creating relationships in the member custom fields.
We looked at creating a custom field for every category type, but there are about 95, and as we add or remove them, it would be extremely cumbersome to try keep up with them all. Even if we did we still aren't sure how to connect 1 member to many categories or many entries via a category.
In sum, the idea is to, using the logged in member, get a quick list of articles, which have been assigned to one of multiple categories, which have been selected as preferences by that logged in member.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个向登录用户显示所有可用类别的表单(使用 channel:categories) 以多选或复选框格式。将该表单发布到一个模板,该模板要么启用了 PHP,要么包含一个简单自定义插件的插件标签...其中之一应该采用发布的类别数组,将它们连接到管道分隔的列表中,然后将其插入到一个简单的新数据库表(带有member_id(使用
{logged_in_member_id}
变量,或在PHP模式下,$this->EE->session->userdata['member_id']
)和类别列表作为列),或者不太理想(但更简单)将它们放在 cookie 中。然后,您可以从数据库或 cookie 中提取该类别列表,并将其用作 "频道:条目标记上的“类别”参数。
Create a form that shows all available categories to the logged-in user (use channel:categories) in either multi-select or checkbox format. POST that form to a template that either has PHP-enabled, or contains a plugin tag of a simple custom plugin ... either one should take the posted array of categories, concatenate them into a pipe-delimited list, and either insert that into a simple new database table (with member_id (use the
{logged_in_member_id}
variable, or in PHP mode,$this->EE->session->userdata['member_id']
) and category list as columns), or less-ideally (but more simply) place them in a cookie.You can then pull that category list out of the database or cookie and use that as the "category" parameter on the channel:entries tag.