Support #7903
Typoscript-Example for adding more fields from DB
| Status: | Closed | Start date: | 2010-05-25 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Bjoern Jacob | % Done: | 100% |
|
| Category: | - | |||
| Target version: | - | |||
| Patch is reviewed: | No | Branch: | ||
| Votes: | 0 |
Description
I want to add more information from my db to be displayed in the shopping cart.
I have a table 'tx_hebest_artikel' containing the basic rticle data and a related table 'tx_hebest_hersteller' that contains producers of articles.
Here is my typoscript to get the things available in the corresponding template:
plugin.tx_wtcart_pi1.settings {
fields {
# change the garbe-icon
delete.file = EXT:he_best/res/garbage.gif
# get the article number
# the first field exists in the main database table: 'tx_hebest_artikel.artikelnummer'
artikelnummer = CONTENT
artikelnummer {
# My database table
table = tx_hebest_artikel
select {
# You have to define the pid of the sysfolder containing the article data here or
# as I did in the example define them as typoscript constant
pidInList = {$plugin.he_best.daten.warenkorb}
andWhere {
# get the uid of the current article, taken from session data
data = field:puid
wrap = uid=|
}
}
# select the value of database field 'artikelnummer' for display
renderObj = COA
renderObj {
10 = TEXT
10.field = artikelnummer
10.wrap = |
}
}
# get the producer title
# the second field exists in table 'tx_hebest_hersteller' and is related to 'tx_hebest_artikel' by join
# the sql select would be:
# SELECT tx_hebest_hersteller.title FROM tx_hebest_hersteller JOIN tx_hebest_artikel ON tx_hebest_artikel.hersteller=tx_hebest_hersteller.uid
# WHERE tx_hebest_artikel.uid = puid
hersteller = CONTENT
hersteller {
table = tx_hebest_hersteller
select {
pidInList = {$plugin.he_best.daten.warenkorb}
selectFields = tx_hebest_hersteller.title
join = tx_hebest_artikel ON (tx_hebest_artikel.hersteller=tx_hebest_hersteller.uid)
andWhere {
data = field:puid
wrap = tx_hebest_artikel.uid=|
}
}
renderObj = COA
renderObj {
10 = TEXT
10.field = title
10.wrap = |
}
}
}
}
# To apply these settings to the powermailCart when you insert ###POWERMAIL_TYPOSCRIPT_CART### you have to copy 'settings.fields' to 'settings.powermailCart.fields''
plugin.tx_wtcart_pi1.settings.powermailCart {
fields < plugin.tx_wtcart_pi1.settings.fields
}
You can use these fields inside the template by writing them marcers uppercase letters:
###ARTIKELNUMMER###
and
###HERSTELLER###
Hope this helps somebody else,
greetings from Esslingen,
Manfred
History
Updated by Bjoern Jacob almost 3 years ago
- Status changed from New to Accepted
- Assignee set to Bjoern Jacob
Thank you Manfred for your TypoScript. Maybe you can also post the constants part. I'll review the code and include it in the manual as an example for getting additional field data. Thanks again! Good work.
Updated by Manfred Mirsch almost 3 years ago
The only line I used from constants is:
plugin.he_best.daten.warenkorb = 89822
That is the sysfolder-ID where the stored data of the referred db-entries are stored.
By the way I also use wt_cart/powermail together with the extension "browser" for implementing the catalogue.
Greetings,
Manfred
Updated by Bjoern Jacob almost 3 years ago
- Priority changed from -- undefined -- to Should have
- % Done changed from 0 to 100
Thanks again Manfred. I've modified your TS a little bit. Now it's included in the recent version. I've added your TS to the manual (FAQ section).
Updated by Bjoern Jacob about 1 month ago
- Status changed from Accepted to Closed
- Patch is reviewed set to No
We're working on a snippet database. This code won't be part of the documentation. Maybe we store it in the snippet DB.