开发者

Linking tables in Drupal 7

开发者 https://www.devze.com 2023-02-16 15:41 出处:网络
I cant figure out how to link fields between 2 content-types in Drupal 7. For example... I\'m building an online shop using Drupal 7. There are several product categories and each category has its ow

I cant figure out how to link fields between 2 content-types in Drupal 7. For example...

I'm building an online shop using Drupal 7. There are several product categories and each category has its own page that displays all the products in that category plus a category description.

I store this data in two tables (content types). See below.

categories content-type:
category_name, description
----------------------------------------------
paintings, "A selection of paintings that we supply. Prices include ...."
ceramics, ....
jewellery, ....

.

products content-type:
name, category_开发者_运维知识库name, price, ...
---------------------------------------------------
mona-lisa, paintings, £10,
necklace1, jewellery, £20,
necklace2, jewellery, £30,

.

The common field is 'category_name'. In the first table I define all the values for category_name and in the second table, each time I add a new product, I want to be able to pick one category to assign to the product. Does anyone know how to do this?

You can reuse fields between content types but you cant change the widget type (the 'categories' content-type needs free-text entry and the 'products' content-type needs a selector.

In Drupal 6 there seemed to be a 'node reference' field type which might be what I'm looking for but I cant figure out how to get this in Drupal7.


This module is still in progress but you can use references for that.

0

精彩评论

暂无评论...
验证码 换一张
取 消