×
If you expect answers you should describe your problem and give as much information's as possible. (SQL-Structure, Template Code, Joomla Version ...) Please read this before posting: joodb.feenders.de/support.html
Linked Tables & Subtemplates
- julius85
- Topic Author
- Offline
Less
More
- Posts: 7
- Thank you received: 0
11 years 6 months ago - 11 years 6 months ago #1139
by julius85
Linked Tables & Subtemplates was created by julius85
hello I have a problem linked tables:
I have to tables: orders and orders_details. The table orders has the general information of the order (id_order, customer, date, etc). and the table orders_details contains all the productos that the customer buy.
So i created a "catalog view templete" to show all the orders and second i created "Linked Tables & Subtemplates" to show the orders_details. My questions is how to make when i clic read more of the catalog view template it send me to the ordes_details.
i dont know if you a tutorial with this steps thanks
I have to tables: orders and orders_details. The table orders has the general information of the order (id_order, customer, date, etc). and the table orders_details contains all the productos that the customer buy.
So i created a "catalog view templete" to show all the orders and second i created "Linked Tables & Subtemplates" to show the orders_details. My questions is how to make when i clic read more of the catalog view template it send me to the ordes_details.
i dont know if you a tutorial with this steps thanks
Last edit: 11 years 6 months ago by joest.
Please Log in to join the conversation.
- Dirk
- Offline
Less
More
- Posts: 1222
- Thank you received: 226
11 years 6 months ago - 11 years 6 months ago #1140
by Dirk
Replied by Dirk on topic Re: Linked Tables & Subtemplates
Both of your Tables must have a primary index field.
I usually name this autoindex id.
To take your example orders is your main table.
Now you have orders_details.
It's a classical 1/N relation.
All you must do is to create a subtemplate and link "orders_details->id_order" => with "order->id". In your subtemplate you just write a how the output of a product-line should happen.
If the name of your subtemplate is "details". Write {joodb subtemplate|details} in the single entry template for your main table "orders"
In your case I would use a N/M relation. That means your order_details table would only be an index linking between your products and the order.
Then you are able to print out product-images, product-details and links to the product view.
Products would be your linked table and orders_details your index-table.
To be honest. Joodb is not made for a shop system. A real shop system is much to complex.
I usually name this autoindex id.
To take your example orders is your main table.
- id (index)
- customer_name (title)
- address
- ...
Now you have orders_details.
- id (index)
- id_order (id of the order -> linked with id field in table orders)
- id_product (optional: id of the product -> linked with the product)
- product_name (title)
- price
- ...
It's a classical 1/N relation.
All you must do is to create a subtemplate and link "orders_details->id_order" => with "order->id". In your subtemplate you just write a how the output of a product-line should happen.
<table>
<tr>
<td style="width:80%">{joodb field|product_name}</td>
<td style="width:20%">{joodb field|price}</td>
</tr>
</table>
If the name of your subtemplate is "details". Write {joodb subtemplate|details} in the single entry template for your main table "orders"
In your case I would use a N/M relation. That means your order_details table would only be an index linking between your products and the order.
- id (index)
- id_order (id of the order -> linked with id field in table orders)
- id_product (id of the product -> linked with the product)
Then you are able to print out product-images, product-details and links to the product view.
Products would be your linked table and orders_details your index-table.
To be honest. Joodb is not made for a shop system. A real shop system is much to complex.
Last edit: 11 years 6 months ago by Dirk.
Please Log in to join the conversation.
Moderators: Dirk, joest