Drupal 7 中的产品分类、查看和添加到菜单
我正在寻找在 Drupal-7 中执行以下操作的想法:
1- 创建产品类别(主类别、子类别以及产品本身...)
例如。 汽车、摩托车...是主要产品类别, 奥迪、丰田...是汽车主类别的子类别, 奥迪A8……就是对应的产品。
2- 动态在菜单项下添加主要类别。
3- 单击主类别项目可查看相关子类别的页面。
4- 单击子类别项目可查看相关产品的图片库。
我尝试使用内容类型和“节点引用”,并使用“视图”有条件地查看它,或使用分类法。但我认为我需要整合这些解决方案才能达到我真正想要的。
使用 drupal 模块我应该遵循哪些步骤,或者它需要自定义模块吗?
提前致谢!
I'm searching for ideas to do the following in Drupal-7:
1- Create product categories (Main category, and sub categories, and products itself...)
ex. Cars, Motor Cycles ... are Main categories of products,
Audi, Toyota ... are subcategories of a Cars main category,
Audi A8 ... is the corresponding product.
2- Dynamically add the Main categories under a menu item.
3- Main category item when clicked view a page of a related Sub-categories.
4- Sub-Category item when clicked view a gallery of images of related products.
I've tried to work with content types and "Node Reference", and view it conditionally using "Views", or working with Taxonomy. But I think I need to integrate those solutions all to reach what I really want.
What steps should I follow using drupal modules, or Will it need a custom module?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您提到的用例最适合分类法。
它的核心。
对于第 1 点:
创建一个名为“产品类别”的分类词汇表。
然后添加术语“汽车”、“摩托车”等。
在汽车术语下创建子术语,称为 Audi、Tayota 等。
现在,在配置分类法后, 将术语参考字段添加到您的内容类型(例如车辆)。现在,您可以在创建车辆内容时将节点与分类术语相关联。
这种方法非常灵活,因为关系层次结构是在单独的接口中维护的,并且没有硬编码到每个节点中。您还可以拥有特定车辆所属的多个术语。就像车辆可以属于 SUV 的子项一样,汽车也可以。
我建议使用分类法,因为它比节点引用更好地处理层次结构(树结构)。您可以在发表观点时利用这一点。
对于第 2 点:
您可以使用分类菜单(贡献的模块)来创建菜单项。否则,显示类型为 Html 列表的视图也可用于列出术语(并显示计数......如汽车(36)、摩托车(22)......等等。
对于第 3 点:
分类法会自动为您提供页面来显示属于某些术语的内容。要显示相关内容,您可以利用视图的帮助。例如
参数 ->分类法:术语 ID(具有深度)将帮助您获取属于子术语的所有节点。现在我知道您不想显示节点,但是术语..这可以通过适当配置字段以仅在视图中显示术语名称来完成。
您可能会发现此处给出的视图导出非常有用。
对于第 4 点:
您将获得分类术语的默认页面,其中显示关联节点的预告片。如果这对您的画廊来说还不够,您可以自己创建子类别的视图,该视图以 term-id 作为参数。
The use case you have mentioned is imo best suited for Taxonomy.
Its in core.
For Point #1:
Create a Taxonomy vocabulary called "Product Categories".
Then add terms "Cars", "Motor Cycles", etc to it.
Now create child terms under Car's term, called Audi, Tayota etc.
After configuring your taxonomy. Add a term reference field to your content type ( say vehicle). Now you can associate your nodes with the taxonomy terms while creating Vehicle contents.
This approach is very flexible cause the relation hierarchy is maintained in a seperate interface and is not hardcoded into each nodes. Also you can have multiple term to which a particular vehicle belongs to. Like a vehicle can be in SUV subterm, as well as Cars.
I suggest using Taxonomy cause, it will handle the hierarchy ( the tree structure ) much better than node references. And you can leverage that while making views.
For Point #2:
You can us Taxonomy Menu ( a contributed Module ) to create teh menu item. Otherwise a view with display type Html List can also be used to list the terms ( and display count as well.. like Cars(36), Motor Cycles(22) ... and so on.
For Point #3:
Taxonomy automatically provides you pages to display content belonging to certain terms. To show related content you can leverage the help of Views. For example
Arguments -> Taxonomy: Term ID (with depth) will help you grab all the nodes belonging to child terms. Now i understand you dont want to show nodes, but Term.. this could be done by configuring field appropriately to show just the term name in views.
You may find the view export given in here very helpful.
For Point #4:
You get a default page for taxonomy term where it shows teaser of associated nodes. If that is not enough for your gallery, you can create a view for sub categories yourself, which takes term-id as argument.